diff --git a/docs/instrumentation-list.yaml b/docs/instrumentation-list.yaml index 0592e3c028de..4369374fcb02 100644 --- a/docs/instrumentation-list.yaml +++ b/docs/instrumentation-list.yaml @@ -4505,6 +4505,11 @@ libraries: type: LONG guava: - name: guava-10.0 + description: | + This instrumentation enables context propagation for Guava ListenableFuture, it does not emit any telemetry on its own. + library_link: https://github.com/google/guava + features: + - CONTEXT_PROPAGATION source_path: instrumentation/guava-10.0 scope: name: io.opentelemetry.guava-10.0 @@ -4513,6 +4518,12 @@ libraries: - com.google.guava:guava:[10.0,] library: - com.google.guava:guava:10.0 + configurations: + - name: otel.instrumentation.guava.experimental-span-attributes + description: Enables experimental span attribute `guava.canceled` for cancelled + operations. + type: boolean + default: false gwt: - name: gwt-2.0 display_name: GWT diff --git a/instrumentation-annotations-support-testing/src/main/java/io/opentelemetry/javaagent/instrumentation/otelannotations/AbstractWithSpanTest.java b/instrumentation-annotations-support-testing/src/main/java/io/opentelemetry/javaagent/instrumentation/otelannotations/AbstractWithSpanTest.java index 06ed5d0d5d61..10f7643bad5e 100644 --- a/instrumentation-annotations-support-testing/src/main/java/io/opentelemetry/javaagent/instrumentation/otelannotations/AbstractWithSpanTest.java +++ b/instrumentation-annotations-support-testing/src/main/java/io/opentelemetry/javaagent/instrumentation/otelannotations/AbstractWithSpanTest.java @@ -43,6 +43,10 @@ protected final InstrumentationExtension testing() { return testing; } + protected boolean isExperimentalSpanAttributesEnabled() { + return true; + } + @Test void success() { AbstractTraced traced = newTraced(); @@ -92,7 +96,10 @@ void canceled() { List attributeAssertions = codeFunctionAssertions(traced.getClass(), "completable"); - attributeAssertions.add(equalTo(booleanKey(canceledKey()), true)); + + if (isExperimentalSpanAttributesEnabled()) { + attributeAssertions.add(equalTo(booleanKey(canceledKey()), true)); + } testing.waitAndAssertTraces( trace -> diff --git a/instrumentation/guava-10.0/javaagent/build.gradle.kts b/instrumentation/guava-10.0/javaagent/build.gradle.kts index 57c6bfc7b064..a432aa870111 100644 --- a/instrumentation/guava-10.0/javaagent/build.gradle.kts +++ b/instrumentation/guava-10.0/javaagent/build.gradle.kts @@ -12,11 +12,6 @@ muzzle { } } -tasks.withType().configureEach { - // TODO run tests both with and without experimental span attributes - jvmArgs("-Dotel.instrumentation.guava.experimental-span-attributes=true") -} - dependencies { bootstrap(project(":instrumentation:executors:bootstrap")) @@ -47,7 +42,14 @@ tasks { jvmArgs("-Dotel.semconv-stability.opt-in=code/dup") } + val testExperimental by registering(Test::class) { + testClassesDirs = sourceSets.test.get().output.classesDirs + classpath = sourceSets.test.get().runtimeClasspath + + jvmArgs("-Dotel.instrumentation.guava.experimental-span-attributes=true") + } + check { - dependsOn(testStableSemconv, testBothSemconv) + dependsOn(testStableSemconv, testBothSemconv, testExperimental) } } diff --git a/instrumentation/guava-10.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/guava/v10_0/BaseGuavaWithSpanTest.java b/instrumentation/guava-10.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/guava/v10_0/BaseGuavaWithSpanTest.java index d12133d8ce28..afaa6c49b4a0 100644 --- a/instrumentation/guava-10.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/guava/v10_0/BaseGuavaWithSpanTest.java +++ b/instrumentation/guava-10.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/guava/v10_0/BaseGuavaWithSpanTest.java @@ -14,6 +14,9 @@ abstract class BaseGuavaWithSpanTest extends AbstractWithSpanTest, ListenableFuture> { + static final boolean isExperimentalEnabled = + Boolean.getBoolean("otel.instrumentation.guava.experimental-span-attributes"); + @Override protected void complete(SettableFuture future, String value) { future.set(value); @@ -43,4 +46,9 @@ protected Throwable unwrapError(Throwable t) { protected String canceledKey() { return "guava.canceled"; } + + @Override + protected boolean isExperimentalSpanAttributesEnabled() { + return isExperimentalEnabled; + } } diff --git a/instrumentation/guava-10.0/metadata.yaml b/instrumentation/guava-10.0/metadata.yaml new file mode 100644 index 000000000000..3f1d71121f24 --- /dev/null +++ b/instrumentation/guava-10.0/metadata.yaml @@ -0,0 +1,11 @@ +description: > + This instrumentation enables context propagation for Guava ListenableFuture, it does not emit + any telemetry on its own. +features: + - CONTEXT_PROPAGATION +library_link: https://github.com/google/guava +configurations: + - name: otel.instrumentation.guava.experimental-span-attributes + description: Enables experimental span attribute `guava.canceled` for cancelled operations. + type: boolean + default: false