couchbase 3.2.0
MODIFY
instrumentation/couchbase/couchbase-3.1.6/javaagent/build.gradle.kts
instrumentation/couchbase/couchbase-3.1.6/javaagent/build.gradle.kts
@@ -6,7 +6,7 @@ muzzle {
pass {
group.set("com.couchbase.client")
module.set("java-client")
- versions.set("[3.1.6,)")
+ versions.set("[3.1.6,3.2.0)")
// these versions were released as ".bundle" instead of ".jar"
skip("2.7.5", "2.7.8")
assertInverse.set(true)
@@ -16,13 +16,14 @@ muzzle {
val versions: Map<String, String> by project
dependencies {
- implementation("com.couchbase.client:tracing-opentelemetry:0.3.6") {
- exclude("com.couchbase.client", "core-io")
- }
+ implementation(project(path = ":instrumentation:couchbase:couchbase-3.1.6:tracing-opentelemetry-shaded", configuration = "shadow"))
library("com.couchbase.client:core-io:2.1.6")
testLibrary("com.couchbase.client:java-client:3.1.6")
testImplementation("org.testcontainers:couchbase:${versions["org.testcontainers"]}")
+
+ latestDepTestLibrary("com.couchbase.client:java-client:3.1.6")
+ latestDepTestLibrary("com.couchbase.client:core-io:2.1.6")
}
\ No newline at end of file

MODIFY
instrumentation/couchbase/couchbase-3.1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v3_1_6/CouchbaseEnvironmentInstrumentation.java
instrumentation/couchbase/couchbase-3.1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v3_1_6/CouchbaseEnvironmentInstrumentation.java
@@ -9,7 +9,7 @@ import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
import static net.bytebuddy.matcher.ElementMatchers.named;
import com.couchbase.client.core.env.CoreEnvironment;
-import com.couchbase.client.tracing.opentelemetry.OpenTelemetryRequestTracer;
+import com.couchbase.v3_1_6.client.tracing.opentelemetry.OpenTelemetryRequestTracer;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;

MODIFY
instrumentation/couchbase/couchbase-3.1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v3_1_6/CouchbaseInstrumentationModule.java
instrumentation/couchbase/couchbase-3.1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v3_1_6/CouchbaseInstrumentationModule.java
@@ -22,7 +22,7 @@ public class CouchbaseInstrumentationModule extends InstrumentationModule {
@Override
public boolean isHelperClass(String className) {
- return className.startsWith("com.couchbase.client.tracing.opentelemetry");
+ return className.startsWith("com.couchbase.v3_1_6.client.tracing.opentelemetry");
}
@Override

ADD
instrumentation/couchbase/couchbase-3.1.6/tracing-opentelemetry-shaded/build.gradle.kts
+plugins {
+ id("com.github.johnrengelman.shadow")
+
+ id("otel.java-conventions")
+}
+
+group = "io.opentelemetry.javaagent.instrumentation"
+
+dependencies {
+ implementation("com.couchbase.client:tracing-opentelemetry:0.3.6")
+}
+
+tasks {
+ shadowJar {
+ dependencies {
+ // including only tracing-opentelemetry excludes its transitive dependencies
+ include(dependency("com.couchbase.client:tracing-opentelemetry"))
+ }
+ relocate("com.couchbase.client.tracing.opentelemetry", "com.couchbase.v3_1_6.client.tracing.opentelemetry")
+ }
+
+ assemble {
+ dependsOn(shadowJar)
+ }
+}
\ No newline at end of file

MODIFY
instrumentation/couchbase/couchbase-3.1/javaagent/build.gradle.kts
instrumentation/couchbase/couchbase-3.1/javaagent/build.gradle.kts
@@ -16,9 +16,7 @@ muzzle {
val versions: Map<String, String> by project
dependencies {
- implementation("com.couchbase.client:tracing-opentelemetry:0.3.3") {
- exclude("com.couchbase.client", "core-io")
- }
+ implementation(project(path = ":instrumentation:couchbase:couchbase-3.1:tracing-opentelemetry-shaded", configuration = "shadow"))
library("com.couchbase.client:core-io:2.1.0")

MODIFY
instrumentation/couchbase/couchbase-3.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v3_1/CouchbaseEnvironmentInstrumentation.java
instrumentation/couchbase/couchbase-3.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v3_1/CouchbaseEnvironmentInstrumentation.java
@@ -9,7 +9,7 @@ import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
import static net.bytebuddy.matcher.ElementMatchers.named;
import com.couchbase.client.core.env.CoreEnvironment;
-import com.couchbase.client.tracing.opentelemetry.OpenTelemetryRequestTracer;
+import com.couchbase.v3_1.client.tracing.opentelemetry.OpenTelemetryRequestTracer;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
@@ -38,7 +38,7 @@ public class CouchbaseEnvironmentInstrumentation implements TypeInstrumentation
public static void onExit(@Advice.This CoreEnvironment.Builder<?> builder) {
builder.requestTracer(
OpenTelemetryRequestTracer.wrap(
- GlobalOpenTelemetry.getTracer("io.opentelemetry.javaagent.couchbase-3.0")));
+ GlobalOpenTelemetry.getTracer("io.opentelemetry.javaagent.couchbase-3.1")));
}
}
}

MODIFY
instrumentation/couchbase/couchbase-3.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v3_1/CouchbaseInstrumentationModule.java
instrumentation/couchbase/couchbase-3.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v3_1/CouchbaseInstrumentationModule.java
@@ -22,7 +22,7 @@ public class CouchbaseInstrumentationModule extends InstrumentationModule {
@Override
public boolean isHelperClass(String className) {
- return className.startsWith("com.couchbase.client.tracing.opentelemetry");
+ return className.startsWith("com.couchbase.v3_1.client.tracing.opentelemetry");
}
@Override

ADD
instrumentation/couchbase/couchbase-3.1/tracing-opentelemetry-shaded/build.gradle.kts
+plugins {
+ id("com.github.johnrengelman.shadow")
+
+ id("otel.java-conventions")
+}
+
+group = "io.opentelemetry.javaagent.instrumentation"
+
+dependencies {
+ implementation("com.couchbase.client:tracing-opentelemetry:0.3.3")
+}
+
+tasks {
+ shadowJar {
+ dependencies {
+ // including only tracing-opentelemetry excludes its transitive dependencies
+ include(dependency("com.couchbase.client:tracing-opentelemetry"))
+ }
+ relocate("com.couchbase.client.tracing.opentelemetry", "com.couchbase.v3_1.client.tracing.opentelemetry")
+ }
+
+ assemble {
+ dependsOn(shadowJar)
+ }
+}
\ No newline at end of file

ADD
instrumentation/couchbase/couchbase-3.2/javaagent/build.gradle.kts
+plugins {
+ id("otel.javaagent-instrumentation")
+}
+
+muzzle {
+ pass {
+ group.set("com.couchbase.client")
+ module.set("java-client")
+ versions.set("[3.2.0,)")
+ // these versions were released as ".bundle" instead of ".jar"
+ skip("2.7.5", "2.7.8")
+ assertInverse.set(true)
+ }
+}
+
+val versions: Map<String, String> by project
+
+dependencies {
+ implementation(project(path = ":instrumentation:couchbase:couchbase-3.2:tracing-opentelemetry-shaded", configuration = "shadow"))
+
+ library("com.couchbase.client:core-io:2.1.6")
+
+ testLibrary("com.couchbase.client:java-client:3.2.0")
+
+ testImplementation("org.testcontainers:couchbase:${versions["org.testcontainers"]}")
+}
\ No newline at end of file

ADD
instrumentation/couchbase/couchbase-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v3_2/CouchbaseEnvironmentInstrumentation.java
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.javaagent.instrumentation.couchbase.v3_2;
+
+import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
+import static net.bytebuddy.matcher.ElementMatchers.named;
+
+import com.couchbase.client.core.env.CoreEnvironment;
+import com.couchbase.v3_2.client.tracing.opentelemetry.OpenTelemetryRequestTracer;
+import io.opentelemetry.api.GlobalOpenTelemetry;
+import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
+import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
+import net.bytebuddy.asm.Advice;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+
+public class CouchbaseEnvironmentInstrumentation implements TypeInstrumentation {
+
+ @Override
+ public ElementMatcher<TypeDescription> typeMatcher() {
+ return named("com.couchbase.client.core.env.CoreEnvironment$Builder");
+ }
+
+ @Override
+ public void transform(TypeTransformer transformer) {
+ transformer.applyAdviceToMethod(
+ isConstructor(),
+ CouchbaseEnvironmentInstrumentation.class.getName() + "$ConstructorAdvice");
+ }
+
+ @SuppressWarnings("unused")
+ public static class ConstructorAdvice {
+
+ @Advice.OnMethodExit(suppress = Throwable.class)
+ public static void onExit(@Advice.This CoreEnvironment.Builder<?> builder) {
+ builder.requestTracer(OpenTelemetryRequestTracer.wrap(GlobalOpenTelemetry.get()));
+ }
+ }
+}

ADD
instrumentation/couchbase/couchbase-3.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v3_2/CouchbaseInstrumentationModule.java
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.javaagent.instrumentation.couchbase.v3_2;
+
+import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
+
+import com.google.auto.service.AutoService;
+import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
+import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
+import java.util.Collections;
+import java.util.List;
+import net.bytebuddy.matcher.ElementMatcher;
+
+@AutoService(InstrumentationModule.class)
+public class CouchbaseInstrumentationModule extends InstrumentationModule {
+ public CouchbaseInstrumentationModule() {
+ super("couchbase", "couchbase-3.1.6");
+ }
+
+ @Override
+ public boolean isHelperClass(String className) {
+ return className.startsWith("com.couchbase.v3_2.client.tracing.opentelemetry");
+ }
+
+ @Override
+ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
+ // New class introduced in 3.2.
+ return hasClassesNamed("com.couchbase.client.core.cnc.RequestSpan$StatusCode");
+ }
+
+ @Override
+ public List<TypeInstrumentation> typeInstrumentations() {
+ return Collections.singletonList(new CouchbaseEnvironmentInstrumentation());
+ }
+}

ADD
instrumentation/couchbase/couchbase-3.2/javaagent/src/test/groovy/CouchbaseClient32Test.groovy
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import com.couchbase.client.core.error.DocumentNotFoundException
+import com.couchbase.client.java.Cluster
+import com.couchbase.client.java.Collection
+import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
+import java.time.Duration
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.testcontainers.containers.output.Slf4jLogConsumer
+import org.testcontainers.couchbase.BucketDefinition
+import org.testcontainers.couchbase.CouchbaseContainer
+import org.testcontainers.couchbase.CouchbaseService
+import spock.lang.Shared
+
+// Couchbase instrumentation is owned upstream so we don't assert on the contents of the spans, only
+// that the instrumentation is properly registered by the agent, meaning some spans were generated.
+class CouchbaseClient32Test extends AgentInstrumentationSpecification {
+ private static final Logger logger = LoggerFactory.getLogger("couchbase-container")
+
+ @Shared
+ CouchbaseContainer couchbase
+ @Shared
+ Cluster cluster
+ @Shared
+ Collection collection
+
+ def setupSpec() {
+ couchbase = new CouchbaseContainer()
+ .withExposedPorts(8091)
+ .withEnabledServices(CouchbaseService.KV)
+ .withBucket(new BucketDefinition("test"))
+ .withLogConsumer(new Slf4jLogConsumer(logger))
+ .withStartupTimeout(Duration.ofSeconds(120))
+ couchbase.start()
+
+ cluster = Cluster.connect(couchbase.connectionString, couchbase.username, couchbase.password)
+ def bucket = cluster.bucket("test")
+ collection = bucket.defaultCollection()
+ bucket.waitUntilReady(Duration.ofSeconds(10))
+ }
+
+ def cleanupSpec() {
+ couchbase.stop()
+ }
+
+ def "emits spans"() {
+ when:
+ try {
+ collection.get("id")
+ } catch (DocumentNotFoundException e) {
+ // Expected
+ }
+
+ then:
+ assertTraces(1) {
+ trace(0, 2) {
+ span(0) {
+ name(~/.*get/)
+ }
+ span(1) {
+ name(~/.*dispatch_to_server/)
+ }
+ }
+ }
+
+ cleanup:
+ cluster.disconnect()
+ }
+}

ADD
instrumentation/couchbase/couchbase-3.2/tracing-opentelemetry-shaded/build.gradle.kts
+plugins {
+ id("com.github.johnrengelman.shadow")
+
+ id("otel.java-conventions")
+}
+
+group = "io.opentelemetry.javaagent.instrumentation"
+
+dependencies {
+ implementation("com.couchbase.client:tracing-opentelemetry:1.0.0")
+}
+
+tasks {
+ shadowJar {
+ dependencies {
+ // including only tracing-opentelemetry excludes its transitive dependencies
+ include(dependency("com.couchbase.client:tracing-opentelemetry"))
+ }
+ relocate("com.couchbase.client.tracing.opentelemetry", "com.couchbase.v3_2.client.tracing.opentelemetry")
+ }
+
+ assemble {
+ dependsOn(shadowJar)
+ }
+}
\ No newline at end of file

MODIFY
settings.gradle.kts
settings.gradle.kts
@@ -120,7 +120,11 @@ include(":instrumentation:couchbase:couchbase-2.0:javaagent")
include(":instrumentation:couchbase:couchbase-2.0:javaagent-unit-tests")
include(":instrumentation:couchbase:couchbase-2.6:javaagent")
include(":instrumentation:couchbase:couchbase-3.1:javaagent")
+include(":instrumentation:couchbase:couchbase-3.1:tracing-opentelemetry-shaded")
include(":instrumentation:couchbase:couchbase-3.1.6:javaagent")
+include(":instrumentation:couchbase:couchbase-3.1.6:tracing-opentelemetry-shaded")
+include(":instrumentation:couchbase:couchbase-3.2:javaagent")
+include(":instrumentation:couchbase:couchbase-3.2:tracing-opentelemetry-shaded")
include(":instrumentation:couchbase:couchbase-testing")
include(":instrumentation:dropwizard-views-0.7:javaagent")
include(":instrumentation:dropwizard-testing")

couchbase 3.2.0 (#3645)