Enabling spring-data integration in test
Enabling the spring-data integration in this test
Mostly, this introduces an extra span for the repository; however, it also connects some previously separate traces under the repository action.
MODIFY
dd-java-agent/instrumentation/elasticsearch/transport-5.3/src/test/groovy/springdata/Elasticsearch53SpringRepositoryTest.groovy
dd-java-agent/instrumentation/elasticsearch/transport-5.3/src/test/groovy/springdata/Elasticsearch53SpringRepositoryTest.groovy
@@ -32,8 +32,14 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
DocRepository getOrCreateRepository() {
if ( repo != null ) return repo;
+ TEST_WRITER.clear()
+ runUnderTrace("setup") {
def applicationContext = new AnnotationConfigApplicationContext(Config)
repo = applicationContext.getBean(DocRepository)
+ }
+ TEST_WRITER.waitForTraces(1)
+ TEST_WRITER.clear()
+
return repo
}
@@ -61,13 +67,25 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
and:
assertTraces(1) {
- trace(0, 1) {
+ trace(0, 2) {
span(0) {
+ operationName "repository.operation"
+ resourceName "CrudRepository.findAll"
+ tags {
+ "$Tags.COMPONENT.key" "spring-data"
+ "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
+ defaultTags()
+ }
+ }
+
+ span(1) {
serviceName "elasticsearch"
resourceName "SearchAction"
operationName "elasticsearch.query"
spanType DDSpanTypes.ELASTICSEARCH
errored false
+ childOf(span(0))
+
tags {
"$Tags.COMPONENT.key" "elasticsearch-java"
"$Tags.DB_TYPE.key" "elasticsearch"
@@ -94,34 +112,23 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
repo.index(doc) == doc
and:
- assertTraces(2) {
- trace(0, 1) {
+ assertTraces(1) {
+ trace(0, 3) {
span(0) {
- resourceName "IndexAction"
- operationName "elasticsearch.query"
- spanType DDSpanTypes.ELASTICSEARCH
+ resourceName "ElasticsearchRepository.index"
+ operationName "repository.operation"
tags {
- "$Tags.COMPONENT.key" "elasticsearch-java"
- "$Tags.DB_TYPE.key" "elasticsearch"
+ "$Tags.COMPONENT.key" "spring-data"
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
- "elasticsearch.action" "IndexAction"
- "elasticsearch.request" "IndexRequest"
- "elasticsearch.request.indices" indexName
- "elasticsearch.request.write.type" "doc"
- "elasticsearch.request.write.version"(-3)
- "elasticsearch.response.status" 201
- "elasticsearch.shard.replication.failed" 0
- "elasticsearch.shard.replication.successful" 1
- "elasticsearch.shard.replication.total" 2
defaultTags()
}
}
- }
- trace(1, 1) {
- span(0) {
+
+ span(1) {
resourceName "RefreshAction"
operationName "elasticsearch.query"
spanType DDSpanTypes.ELASTICSEARCH
+ childOf(span(0))
tags {
"$Tags.COMPONENT.key" "elasticsearch-java"
"$Tags.DB_TYPE.key" "elasticsearch"
@@ -135,6 +142,28 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
defaultTags()
}
}
+
+ span(2) {
+ resourceName "IndexAction"
+ operationName "elasticsearch.query"
+ spanType DDSpanTypes.ELASTICSEARCH
+ childOf(span(0))
+ tags {
+ "$Tags.COMPONENT.key" "elasticsearch-java"
+ "$Tags.DB_TYPE.key" "elasticsearch"
+ "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
+ "elasticsearch.action" "IndexAction"
+ "elasticsearch.request" "IndexRequest"
+ "elasticsearch.request.indices" indexName
+ "elasticsearch.request.write.type" "doc"
+ "elasticsearch.request.write.version"(-3)
+ "elasticsearch.response.status" 201
+ "elasticsearch.shard.replication.failed" 0
+ "elasticsearch.shard.replication.successful" 1
+ "elasticsearch.shard.replication.total" 2
+ defaultTags()
+ }
+ }
}
}
TEST_WRITER.clear()
@@ -144,12 +173,23 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
and:
assertTraces(1) {
- trace(0, 1) {
+ trace(0, 2) {
span(0) {
+ resourceName "CrudRepository.findById"
+ operationName "repository.operation"
+ tags {
+ "$Tags.COMPONENT.key" "spring-data"
+ "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
+ defaultTags()
+ }
+ }
+
+ span(1) {
serviceName "elasticsearch"
resourceName "GetAction"
operationName "elasticsearch.query"
spanType DDSpanTypes.ELASTICSEARCH
+ childOf(span(0))
tags {
"$Tags.COMPONENT.key" "elasticsearch-java"
"$Tags.DB_TYPE.key" "elasticsearch"
@@ -175,12 +215,40 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
repo.findById("1").get() == doc
and:
- assertTraces(3) {
- trace(0, 1) {
+ assertTraces(2) {
+ trace(0, 3) {
span(0) {
+ resourceName "ElasticsearchRepository.index"
+ operationName "repository.operation"
+ tags {
+ "$Tags.COMPONENT.key" "spring-data"
+ "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
+ defaultTags()
+ }
+ }
+ span(1) {
+ resourceName "RefreshAction"
+ operationName "elasticsearch.query"
+ spanType DDSpanTypes.ELASTICSEARCH
+ childOf(span(0))
+ tags {
+ "$Tags.COMPONENT.key" "elasticsearch-java"
+ "$Tags.DB_TYPE.key" "elasticsearch"
+ "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
+ "elasticsearch.action" "RefreshAction"
+ "elasticsearch.request" "RefreshRequest"
+ "elasticsearch.request.indices" indexName
+ "elasticsearch.shard.broadcast.failed" 0
+ "elasticsearch.shard.broadcast.successful" 5
+ "elasticsearch.shard.broadcast.total" 10
+ defaultTags()
+ }
+ }
+ span(2) {
resourceName "IndexAction"
operationName "elasticsearch.query"
spanType DDSpanTypes.ELASTICSEARCH
+ childOf(span(0))
tags {
"$Tags.COMPONENT.key" "elasticsearch-java"
"$Tags.DB_TYPE.key" "elasticsearch"
@@ -198,31 +266,23 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
}
}
}
- trace(1, 1) {
+ trace(1, 2) {
span(0) {
- resourceName "RefreshAction"
- operationName "elasticsearch.query"
- spanType DDSpanTypes.ELASTICSEARCH
+ resourceName "CrudRepository.findById"
+ operationName "repository.operation"
tags {
- "$Tags.COMPONENT.key" "elasticsearch-java"
- "$Tags.DB_TYPE.key" "elasticsearch"
+ "$Tags.COMPONENT.key" "spring-data"
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
- "elasticsearch.action" "RefreshAction"
- "elasticsearch.request" "RefreshRequest"
- "elasticsearch.request.indices" indexName
- "elasticsearch.shard.broadcast.failed" 0
- "elasticsearch.shard.broadcast.successful" 5
- "elasticsearch.shard.broadcast.total" 10
defaultTags()
}
}
- }
- trace(2, 1) {
- span(0) {
+
+ span(1) {
serviceName "elasticsearch"
resourceName "GetAction"
operationName "elasticsearch.query"
spanType DDSpanTypes.ELASTICSEARCH
+ childOf(span(0))
tags {
"$Tags.COMPONENT.key" "elasticsearch-java"
"$Tags.DB_TYPE.key" "elasticsearch"
@@ -247,12 +307,41 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
!repo.findAll().iterator().hasNext()
and:
- assertTraces(3) {
- trace(0, 1) {
+ assertTraces(2) {
+ trace(0, 3) {
span(0) {
+ resourceName "CrudRepository.deleteById"
+ operationName "repository.operation"
+ tags {
+ "$Tags.COMPONENT.key" "spring-data"
+ "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
+ defaultTags()
+ }
+ }
+
+ span(1) {
+ resourceName "RefreshAction"
+ operationName "elasticsearch.query"
+ spanType DDSpanTypes.ELASTICSEARCH
+ childOf(span(0))
+ tags {
+ "$Tags.COMPONENT.key" "elasticsearch-java"
+ "$Tags.DB_TYPE.key" "elasticsearch"
+ "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
+ "elasticsearch.action" "RefreshAction"
+ "elasticsearch.request" "RefreshRequest"
+ "elasticsearch.request.indices" indexName
+ "elasticsearch.shard.broadcast.failed" 0
+ "elasticsearch.shard.broadcast.successful" 5
+ "elasticsearch.shard.broadcast.total" 10
+ defaultTags()
+ }
+ }
+ span(2) {
resourceName "DeleteAction"
operationName "elasticsearch.query"
spanType DDSpanTypes.ELASTICSEARCH
+ childOf(span(0))
tags {
"$Tags.COMPONENT.key" "elasticsearch-java"
"$Tags.DB_TYPE.key" "elasticsearch"
@@ -269,31 +358,24 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
}
}
}
- trace(1, 1) {
+
+ trace(1, 2) {
span(0) {
- resourceName "RefreshAction"
- operationName "elasticsearch.query"
- spanType DDSpanTypes.ELASTICSEARCH
+ resourceName "CrudRepository.findAll"
+ operationName "repository.operation"
tags {
- "$Tags.COMPONENT.key" "elasticsearch-java"
- "$Tags.DB_TYPE.key" "elasticsearch"
+ "$Tags.COMPONENT.key" "spring-data"
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
- "elasticsearch.action" "RefreshAction"
- "elasticsearch.request" "RefreshRequest"
- "elasticsearch.request.indices" indexName
- "elasticsearch.shard.broadcast.failed" 0
- "elasticsearch.shard.broadcast.successful" 5
- "elasticsearch.shard.broadcast.total" 10
defaultTags()
}
}
- }
- trace(2, 1) {
- span(0) {
+
+ span(1) {
serviceName "elasticsearch"
resourceName "SearchAction"
operationName "elasticsearch.query"
spanType DDSpanTypes.ELASTICSEARCH
+ childOf(span(0))
tags {
"$Tags.COMPONENT.key" "elasticsearch-java"
"$Tags.DB_TYPE.key" "elasticsearch"

MODIFY
dd-java-agent/instrumentation/elasticsearch/transport-5.3/transport-5.3.gradle
dd-java-agent/instrumentation/elasticsearch/transport-5.3/transport-5.3.gradle
@@ -35,7 +35,7 @@ dependencies {
testCompile project(':dd-java-agent:instrumentation:apache-httpasyncclient-4')
testCompile project(':dd-java-agent:instrumentation:netty-4.1')
- // testCompile project(':dd-java-agent:instrumentation:spring-data-1.9')
+ testCompile project(':dd-java-agent:instrumentation:spring-data-1.9')
testCompile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
testCompile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'

Enabling spring-data integration in test

Enabling the spring-data integration in this test

Mostly, this introduces an extra span for the repository; however, it also connects some previously separate traces under the repository action.