Add span.type and remove bucket name from resource.name
MODIFY
dd-java-agent/instrumentation/couchbase-2.0/src/main/java/datadog/trace/instrumentation/couchbase/client/CouchbaseBucketInstrumentation.java
dd-java-agent/instrumentation/couchbase-2.0/src/main/java/datadog/trace/instrumentation/couchbase/client/CouchbaseBucketInstrumentation.java
@@ -11,6 +11,7 @@ import static net.bytebuddy.matcher.ElementMatchers.returns;
import com.couchbase.client.java.CouchbaseCluster;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
+import datadog.trace.api.DDSpanTypes;
import datadog.trace.api.DDTags;
import datadog.trace.bootstrap.CallDepthThreadLocalMap;
import io.opentracing.Span;
@@ -107,7 +108,7 @@ public class CouchbaseBucketInstrumentation extends Instrumenter.Default {
final Class<?> declaringClass = method.getDeclaringClass();
final String className =
declaringClass.getSimpleName().replace("CouchbaseAsync", "").replace("DefaultAsync", "");
- final String resourceName = className + "." + method.getName() + "(" + bucket + ")";
+ final String resourceName = className + "." + method.getName();
// just replace the no-op span.
spanRef.set(
@@ -115,6 +116,7 @@ public class CouchbaseBucketInstrumentation extends Instrumenter.Default {
.buildSpan("couchbase.call")
.withTag(DDTags.SERVICE_NAME, "couchbase")
.withTag(DDTags.RESOURCE_NAME, resourceName)
+ .withTag(DDTags.SPAN_TYPE, DDSpanTypes.COUCHBASE)
.withTag("bucket", bucket)
.start());
}

MODIFY
dd-java-agent/instrumentation/couchbase-2.0/src/main/java/datadog/trace/instrumentation/couchbase/client/CouchbaseClusterInstrumentation.java
dd-java-agent/instrumentation/couchbase-2.0/src/main/java/datadog/trace/instrumentation/couchbase/client/CouchbaseClusterInstrumentation.java
@@ -11,6 +11,7 @@ import static net.bytebuddy.matcher.ElementMatchers.returns;
import com.couchbase.client.java.CouchbaseCluster;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
+import datadog.trace.api.DDSpanTypes;
import datadog.trace.api.DDTags;
import datadog.trace.bootstrap.CallDepthThreadLocalMap;
import io.opentracing.Span;
@@ -110,6 +111,7 @@ public class CouchbaseClusterInstrumentation extends Instrumenter.Default {
.buildSpan("couchbase.call")
.withTag(DDTags.SERVICE_NAME, "couchbase")
.withTag(DDTags.RESOURCE_NAME, resourceName)
+ .withTag(DDTags.SPAN_TYPE, DDSpanTypes.COUCHBASE)
.start());
}
}

MODIFY
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/CouchbaseClientTest.groovy
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/CouchbaseClientTest.groovy
@@ -2,6 +2,8 @@ import com.couchbase.client.java.Bucket
import com.couchbase.client.java.document.JsonDocument
import com.couchbase.client.java.document.json.JsonObject
import com.couchbase.client.java.query.N1qlQuery
+import datadog.trace.api.DDSpanTypes
+import datadog.trace.api.DDTags
import util.AbstractCouchbaseTest
import static datadog.trace.agent.test.asserts.ListWriterAssert.assertTraces
@@ -22,6 +24,7 @@ class CouchbaseClientTest extends AbstractCouchbaseTest {
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
defaultTags()
}
}
@@ -42,11 +45,12 @@ class CouchbaseClientTest extends AbstractCouchbaseTest {
trace(0, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.upsert(${bkt.name()})"
+ resourceName "Bucket.upsert"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" bkt.name()
defaultTags()
}
@@ -67,11 +71,12 @@ class CouchbaseClientTest extends AbstractCouchbaseTest {
trace(0, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.get(${bkt.name()})"
+ resourceName "Bucket.get"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" bkt.name()
defaultTags()
}
@@ -108,11 +113,12 @@ class CouchbaseClientTest extends AbstractCouchbaseTest {
trace(0, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.query(${bkt.name()})"
+ resourceName "Bucket.query"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" bkt.name()
defaultTags()
}

MODIFY
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/springdata/CouchbaseSpringRepositoryTest.groovy
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/springdata/CouchbaseSpringRepositoryTest.groovy
@@ -2,6 +2,8 @@ package springdata
import com.couchbase.client.java.view.DefaultView
import com.couchbase.client.java.view.DesignDocument
+import datadog.trace.api.DDSpanTypes
+import datadog.trace.api.DDTags
import org.springframework.context.ConfigurableApplicationContext
import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.data.repository.CrudRepository
@@ -77,11 +79,12 @@ class CouchbaseSpringRepositoryTest extends AbstractCouchbaseTest {
trace(0, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.query(${bucketCouchbase.name()})"
+ resourceName "Bucket.query"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" bucketCouchbase.name()
defaultTags()
}
@@ -105,11 +108,12 @@ class CouchbaseSpringRepositoryTest extends AbstractCouchbaseTest {
trace(0, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.upsert(${bucketCouchbase.name()})"
+ resourceName "Bucket.upsert"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" bucketCouchbase.name()
defaultTags()
}
@@ -126,11 +130,12 @@ class CouchbaseSpringRepositoryTest extends AbstractCouchbaseTest {
trace(0, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.get(${bucketCouchbase.name()})"
+ resourceName "Bucket.get"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" bucketCouchbase.name()
defaultTags()
}
@@ -150,11 +155,12 @@ class CouchbaseSpringRepositoryTest extends AbstractCouchbaseTest {
trace(0, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.upsert(${bucketCouchbase.name()})"
+ resourceName "Bucket.upsert"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" bucketCouchbase.name()
defaultTags()
}
@@ -163,11 +169,12 @@ class CouchbaseSpringRepositoryTest extends AbstractCouchbaseTest {
trace(1, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.query(${bucketCouchbase.name()})"
+ resourceName "Bucket.query"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" bucketCouchbase.name()
defaultTags()
}
@@ -176,11 +183,12 @@ class CouchbaseSpringRepositoryTest extends AbstractCouchbaseTest {
trace(2, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.get(${bucketCouchbase.name()})"
+ resourceName "Bucket.get"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" bucketCouchbase.name()
defaultTags()
}
@@ -200,11 +208,12 @@ class CouchbaseSpringRepositoryTest extends AbstractCouchbaseTest {
trace(0, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.remove(${bucketCouchbase.name()})"
+ resourceName "Bucket.remove"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" bucketCouchbase.name()
defaultTags()
}
@@ -213,11 +222,12 @@ class CouchbaseSpringRepositoryTest extends AbstractCouchbaseTest {
trace(1, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.query(${bucketCouchbase.name()})"
+ resourceName "Bucket.query"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" bucketCouchbase.name()
defaultTags()
}

MODIFY
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/springdata/CouchbaseSpringTemplateTest.groovy
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/springdata/CouchbaseSpringTemplateTest.groovy
@@ -2,6 +2,8 @@ package springdata
import com.couchbase.client.java.Bucket
+import datadog.trace.api.DDSpanTypes
+import datadog.trace.api.DDTags
import org.springframework.data.couchbase.core.CouchbaseTemplate
import spock.lang.Shared
import util.AbstractCouchbaseTest
@@ -43,11 +45,12 @@ class CouchbaseSpringTemplateTest extends AbstractCouchbaseTest {
trace(0, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.upsert($name)"
+ resourceName "Bucket.upsert"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" name
defaultTags()
}
@@ -56,11 +59,12 @@ class CouchbaseSpringTemplateTest extends AbstractCouchbaseTest {
trace(1, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.get($name)"
+ resourceName "Bucket.get"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" name
defaultTags()
}
@@ -69,11 +73,12 @@ class CouchbaseSpringTemplateTest extends AbstractCouchbaseTest {
trace(2, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.remove($name)"
+ resourceName "Bucket.remove"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" name
defaultTags()
}
@@ -82,11 +87,12 @@ class CouchbaseSpringTemplateTest extends AbstractCouchbaseTest {
trace(3, 1) {
span(0) {
serviceName "couchbase"
- resourceName "Bucket.get($name)"
+ resourceName "Bucket.get"
operationName "couchbase.call"
errored false
parent()
tags {
+ "$DDTags.SPAN_TYPE" DDSpanTypes.COUCHBASE
"bucket" name
defaultTags()
}

MODIFY
dd-trace-api/src/main/java/datadog/trace/api/DDSpanTypes.java
dd-trace-api/src/main/java/datadog/trace/api/DDSpanTypes.java
@@ -10,6 +10,7 @@ public class DDSpanTypes {
public static final String SQL = "sql";
public static final String MONGO = "mongodb";
public static final String CASSANDRA = "cassandra";
+ public static final String COUCHBASE = "db"; // Using generic for now.
public static final String REDIS = "redis";
public static final String MEMCACHED = "memcached";
public static final String ELASTICSEARCH = "elasticsearch";

Add span.type and remove bucket name from resource.name