Skip to content

Commit 4336748

Browse files
committed
otel annotations
1 parent 64ea006 commit 4336748

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
import static io.opentelemetry.api.common.AttributeKey.booleanKey;
99
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
10-
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION;
11-
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_NAMESPACE;
10+
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION_NAME;
1211
import static org.assertj.core.api.Assertions.assertThat;
1312
import static org.assertj.core.api.Assertions.catchThrowable;
1413

@@ -19,7 +18,6 @@
1918
import org.junit.jupiter.api.Test;
2019
import org.junit.jupiter.api.extension.RegisterExtension;
2120

22-
@SuppressWarnings("deprecation") // CodeIncubatingAttributes.CODE_FUNCTION is deprecated
2321
public abstract class AbstractWithSpanTest<T extends U, U> {
2422

2523
@RegisterExtension
@@ -59,8 +57,9 @@ void success() {
5957
.hasKind(SpanKind.INTERNAL)
6058
.hasNoParent()
6159
.hasAttributesSatisfyingExactly(
62-
equalTo(CODE_NAMESPACE, traced.getClass().getName()),
63-
equalTo(CODE_FUNCTION, "completable"))));
60+
equalTo(
61+
CODE_FUNCTION_NAME,
62+
traced.getClass().getCanonicalName() + ".completable"))));
6463
}
6564

6665
@Test
@@ -82,8 +81,7 @@ void failure() {
8281
.hasStatus(StatusData.error())
8382
.hasException(AbstractTraced.FAILURE)
8483
.hasAttributesSatisfyingExactly(
85-
equalTo(CODE_NAMESPACE, traced.getClass().getName()),
86-
equalTo(CODE_FUNCTION, "completable"))));
84+
equalTo(CODE_FUNCTION_NAME, traced.getClass().getName()+".completable"))));
8785
}
8886

8987
@Test
@@ -100,8 +98,7 @@ void canceled() {
10098
.hasKind(SpanKind.INTERNAL)
10199
.hasNoParent()
102100
.hasAttributesSatisfyingExactly(
103-
equalTo(CODE_NAMESPACE, traced.getClass().getName()),
104-
equalTo(CODE_FUNCTION, "completable"),
101+
equalTo(CODE_FUNCTION_NAME, traced.getClass().getName()+".completable"),
105102
equalTo(booleanKey(canceledKey()), true))));
106103
}
107104

@@ -118,8 +115,7 @@ void immediateSuccess() {
118115
.hasKind(SpanKind.INTERNAL)
119116
.hasNoParent()
120117
.hasAttributesSatisfyingExactly(
121-
equalTo(CODE_NAMESPACE, traced.getClass().getName()),
122-
equalTo(CODE_FUNCTION, "alreadySucceeded"))));
118+
equalTo(CODE_FUNCTION_NAME, traced.getClass().getName()+".alreadySucceeded"))));
123119
}
124120

125121
@Test
@@ -138,7 +134,6 @@ void immediateFailure() {
138134
.hasStatus(StatusData.error())
139135
.hasException(AbstractTraced.FAILURE)
140136
.hasAttributesSatisfyingExactly(
141-
equalTo(CODE_NAMESPACE, traced.getClass().getName()),
142-
equalTo(CODE_FUNCTION, "alreadyFailed"))));
137+
equalTo(CODE_FUNCTION_NAME, traced.getClass().getName()+".alreadyFailed"))));
143138
}
144139
}

instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/src/test/java/io/opentelemetry/test/annotation/AddingSpanAttributesInstrumentationTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
import static io.opentelemetry.api.common.AttributeKey.stringKey;
99
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
1010
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
11-
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION;
12-
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_NAMESPACE;
11+
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION_NAME;
1312

1413
import io.opentelemetry.api.trace.Span;
1514
import io.opentelemetry.api.trace.SpanKind;
@@ -43,9 +42,9 @@ void captureAttributesInNewSpan() {
4342
.hasParentSpanId(trace.getSpan(0).getSpanId())
4443
.hasAttributesSatisfyingExactly(
4544
equalTo(
46-
CODE_NAMESPACE,
47-
ExtractAttributesUsingAddingSpanAttributes.class.getName()),
48-
equalTo(CODE_FUNCTION, "withSpanTakesPrecedence"),
45+
CODE_FUNCTION_NAME,
46+
ExtractAttributesUsingAddingSpanAttributes.class.getName()
47+
+ ".withSpanTakesPrecedence"),
4948
equalTo(stringKey("implicitName"), "foo"),
5049
equalTo(stringKey("explicitName"), "bar"))));
5150
}

0 commit comments

Comments
 (0)