Skip to content

Commit 9632d82

Browse files
committed
Metadata and test refactor for guava
1 parent ce90a0e commit 9632d82

File tree

5 files changed

+46
-7
lines changed

5 files changed

+46
-7
lines changed

docs/instrumentation-list.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4505,6 +4505,11 @@ libraries:
45054505
type: LONG
45064506
guava:
45074507
- name: guava-10.0
4508+
description: |
4509+
This instrumentation enables context propagation for Guava ListenableFuture, it does not emit any telemetry on its own.
4510+
library_link: https://github.com/google/guava
4511+
features:
4512+
- CONTEXT_PROPAGATION
45084513
source_path: instrumentation/guava-10.0
45094514
scope:
45104515
name: io.opentelemetry.guava-10.0
@@ -4513,6 +4518,12 @@ libraries:
45134518
- com.google.guava:guava:[10.0,]
45144519
library:
45154520
- com.google.guava:guava:10.0
4521+
configurations:
4522+
- name: otel.instrumentation.guava.experimental-span-attributes
4523+
description: Enables experimental span attribute `guava.canceled` for cancelled
4524+
operations.
4525+
type: boolean
4526+
default: false
45164527
gwt:
45174528
- name: gwt-2.0
45184529
display_name: GWT

instrumentation-annotations-support-testing/src/main/java/io/opentelemetry/javaagent/instrumentation/otelannotations/AbstractWithSpanTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ protected final InstrumentationExtension testing() {
4343
return testing;
4444
}
4545

46+
protected boolean isExperimentalSpanAttributesEnabled() {
47+
return true;
48+
}
49+
4650
@Test
4751
void success() {
4852
AbstractTraced<T, U> traced = newTraced();
@@ -92,7 +96,10 @@ void canceled() {
9296

9397
List<AttributeAssertion> attributeAssertions =
9498
codeFunctionAssertions(traced.getClass(), "completable");
95-
attributeAssertions.add(equalTo(booleanKey(canceledKey()), true));
99+
100+
if (isExperimentalSpanAttributesEnabled()) {
101+
attributeAssertions.add(equalTo(booleanKey(canceledKey()), true));
102+
}
96103

97104
testing.waitAndAssertTraces(
98105
trace ->

instrumentation/guava-10.0/javaagent/build.gradle.kts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ muzzle {
1212
}
1313
}
1414

15-
tasks.withType<Test>().configureEach {
16-
// TODO run tests both with and without experimental span attributes
17-
jvmArgs("-Dotel.instrumentation.guava.experimental-span-attributes=true")
18-
}
19-
2015
dependencies {
2116
bootstrap(project(":instrumentation:executors:bootstrap"))
2217

@@ -47,7 +42,14 @@ tasks {
4742
jvmArgs("-Dotel.semconv-stability.opt-in=code/dup")
4843
}
4944

45+
val testExperimental by registering(Test::class) {
46+
testClassesDirs = sourceSets.test.get().output.classesDirs
47+
classpath = sourceSets.test.get().runtimeClasspath
48+
49+
jvmArgs("-Dotel.instrumentation.guava.experimental-span-attributes=true")
50+
}
51+
5052
check {
51-
dependsOn(testStableSemconv, testBothSemconv)
53+
dependsOn(testStableSemconv, testBothSemconv, testExperimental)
5254
}
5355
}

instrumentation/guava-10.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/guava/v10_0/BaseGuavaWithSpanTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
abstract class BaseGuavaWithSpanTest
1515
extends AbstractWithSpanTest<SettableFuture<String>, ListenableFuture<String>> {
1616

17+
static final boolean isExperimentalEnabled =
18+
Boolean.getBoolean("otel.instrumentation.guava.experimental-span-attributes");
19+
1720
@Override
1821
protected void complete(SettableFuture<String> future, String value) {
1922
future.set(value);
@@ -43,4 +46,9 @@ protected Throwable unwrapError(Throwable t) {
4346
protected String canceledKey() {
4447
return "guava.canceled";
4548
}
49+
50+
@Override
51+
protected boolean isExperimentalSpanAttributesEnabled() {
52+
return isExperimentalEnabled;
53+
}
4654
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
description: >
2+
This instrumentation enables context propagation for Guava ListenableFuture, it does not emit
3+
any telemetry on its own.
4+
features:
5+
- CONTEXT_PROPAGATION
6+
library_link: https://github.com/google/guava
7+
configurations:
8+
- name: otel.instrumentation.guava.experimental-span-attributes
9+
description: Enables experimental span attribute `guava.canceled` for cancelled operations.
10+
type: boolean
11+
default: false

0 commit comments

Comments
 (0)