99import static io .opentelemetry .instrumentation .testing .util .TelemetryDataUtil .orderByRootSpanName ;
1010import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .assertThat ;
1111import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .equalTo ;
12- import static io .opentelemetry .semconv .incubating .CodeIncubatingAttributes .CODE_FUNCTION ;
13- import static io .opentelemetry .semconv .incubating .CodeIncubatingAttributes .CODE_NAMESPACE ;
12+ import static io .opentelemetry .semconv .incubating .CodeIncubatingAttributes .CODE_FUNCTION_NAME ;
1413
1514import io .opentelemetry .api .common .Attributes ;
1615import io .opentelemetry .api .trace .SpanId ;
3130import org .junit .jupiter .api .Test ;
3231import org .junit .jupiter .api .extension .RegisterExtension ;
3332
34- @ SuppressWarnings ("deprecation" ) // using deprecated semconv
3533class WithSpanInstrumentationTest {
3634
3735 @ RegisterExtension
@@ -50,8 +48,8 @@ void deriveAutomaticName() {
5048 .hasKind (SpanKind .INTERNAL )
5149 .hasNoParent ()
5250 .hasAttributesSatisfyingExactly (
53- equalTo (CODE_NAMESPACE , TracedWithSpan . class . getName ()),
54- equalTo ( CODE_FUNCTION , " otel" ))));
51+ equalTo (
52+ CODE_FUNCTION_NAME , TracedWithSpan . class . getName () + ". otel" ))));
5553 }
5654
5755 @ Test
@@ -66,8 +64,9 @@ void manualName() {
6664 .hasKind (SpanKind .INTERNAL )
6765 .hasNoParent ()
6866 .hasAttributesSatisfyingExactly (
69- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
70- equalTo (CODE_FUNCTION , "namedOtel" ))));
67+ equalTo (
68+ CODE_FUNCTION_NAME ,
69+ TracedWithSpan .class .getName () + ".namedOtel" ))));
7170 }
7271
7372 @ Test
@@ -82,8 +81,9 @@ void manualKind() {
8281 .hasKind (SpanKind .PRODUCER )
8382 .hasParentSpanId (SpanId .getInvalid ())
8483 .hasAttributesSatisfyingExactly (
85- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
86- equalTo (CODE_FUNCTION , "someKind" ))));
84+ equalTo (
85+ CODE_FUNCTION_NAME ,
86+ TracedWithSpan .class .getName () + ".someKind" ))));
8787 }
8888
8989 @ Test
@@ -98,15 +98,15 @@ void multipleSpans() {
9898 .hasKind (SpanKind .SERVER )
9999 .hasNoParent ()
100100 .hasAttributesSatisfyingExactly (
101- equalTo (CODE_NAMESPACE , TracedWithSpan . class . getName ()),
102- equalTo ( CODE_FUNCTION , " server" )),
101+ equalTo (
102+ CODE_FUNCTION_NAME , TracedWithSpan . class . getName () + ". server" )),
103103 span ->
104104 span .hasName ("TracedWithSpan.otel" )
105105 .hasKind (SpanKind .INTERNAL )
106106 .hasParentSpanId (trace .getSpan (0 ).getSpanId ())
107107 .hasAttributesSatisfyingExactly (
108- equalTo (CODE_NAMESPACE , TracedWithSpan . class . getName ()),
109- equalTo ( CODE_FUNCTION , " otel" ))));
108+ equalTo (
109+ CODE_FUNCTION_NAME , TracedWithSpan . class . getName () + ". otel" ))));
110110 }
111111
112112 @ Test
@@ -122,17 +122,18 @@ void multipleSpansWithoutParent() {
122122 .hasKind (SpanKind .CONSUMER )
123123 .hasNoParent ()
124124 .hasAttributesSatisfyingExactly (
125- equalTo (CODE_NAMESPACE , TracedWithSpan . class . getName ()),
126- equalTo ( CODE_FUNCTION , " consumer" ))),
125+ equalTo (
126+ CODE_FUNCTION_NAME , TracedWithSpan . class . getName () + ". consumer" ))),
127127 trace ->
128128 trace .hasSpansSatisfyingExactly (
129129 span ->
130130 span .hasName ("TracedWithSpan.withoutParent" )
131131 .hasKind (SpanKind .INTERNAL )
132132 .hasNoParent ()
133133 .hasAttributesSatisfyingExactly (
134- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
135- equalTo (CODE_FUNCTION , "withoutParent" ))));
134+ equalTo (
135+ CODE_FUNCTION_NAME ,
136+ TracedWithSpan .class .getName () + ".withoutParent" ))));
136137 }
137138
138139 @ Test
@@ -156,8 +157,9 @@ void completedCompletionStage() {
156157 .hasKind (SpanKind .INTERNAL )
157158 .hasNoParent ()
158159 .hasAttributesSatisfyingExactly (
159- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
160- equalTo (CODE_FUNCTION , "completionStage" ))));
160+ equalTo (
161+ CODE_FUNCTION_NAME ,
162+ TracedWithSpan .class .getName () + ".completionStage" ))));
161163 }
162164
163165 @ Test
@@ -175,8 +177,9 @@ void exceptionallyCompletedCompletionStage() {
175177 .hasNoParent ()
176178 .hasStatus (StatusData .error ())
177179 .hasAttributesSatisfyingExactly (
178- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
179- equalTo (CODE_FUNCTION , "completionStage" ))));
180+ equalTo (
181+ CODE_FUNCTION_NAME ,
182+ TracedWithSpan .class .getName () + ".completionStage" ))));
180183 }
181184
182185 @ Test
@@ -191,8 +194,9 @@ void nullCompletionStage() {
191194 .hasKind (SpanKind .INTERNAL )
192195 .hasNoParent ()
193196 .hasAttributesSatisfyingExactly (
194- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
195- equalTo (CODE_FUNCTION , "completionStage" ))));
197+ equalTo (
198+ CODE_FUNCTION_NAME ,
199+ TracedWithSpan .class .getName () + ".completionStage" ))));
196200 }
197201
198202 @ Test
@@ -213,8 +217,9 @@ void completingCompletionStage() throws Exception {
213217 .hasKind (SpanKind .INTERNAL )
214218 .hasNoParent ()
215219 .hasAttributesSatisfyingExactly (
216- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
217- equalTo (CODE_FUNCTION , "completionStage" ))));
220+ equalTo (
221+ CODE_FUNCTION_NAME ,
222+ TracedWithSpan .class .getName () + ".completionStage" ))));
218223 }
219224
220225 @ Test
@@ -236,8 +241,9 @@ void exceptionallyCompletingCompletionStage() throws Exception {
236241 .hasNoParent ()
237242 .hasStatus (StatusData .error ())
238243 .hasAttributesSatisfyingExactly (
239- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
240- equalTo (CODE_FUNCTION , "completionStage" ))));
244+ equalTo (
245+ CODE_FUNCTION_NAME ,
246+ TracedWithSpan .class .getName () + ".completionStage" ))));
241247 }
242248
243249 @ Test
@@ -253,8 +259,9 @@ void completedCompletableFuture() {
253259 .hasKind (SpanKind .INTERNAL )
254260 .hasNoParent ()
255261 .hasAttributesSatisfyingExactly (
256- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
257- equalTo (CODE_FUNCTION , "completableFuture" ))));
262+ equalTo (
263+ CODE_FUNCTION_NAME ,
264+ TracedWithSpan .class .getName () + ".completableFuture" ))));
258265 }
259266
260267 @ Test
@@ -272,8 +279,9 @@ void exceptionallyCompletedCompletableFuture() {
272279 .hasNoParent ()
273280 .hasStatus (StatusData .error ())
274281 .hasAttributesSatisfyingExactly (
275- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
276- equalTo (CODE_FUNCTION , "completableFuture" ))));
282+ equalTo (
283+ CODE_FUNCTION_NAME ,
284+ TracedWithSpan .class .getName () + ".completableFuture" ))));
277285 }
278286
279287 @ Test
@@ -288,8 +296,9 @@ void nullCompletableFuture() {
288296 .hasKind (SpanKind .INTERNAL )
289297 .hasNoParent ()
290298 .hasAttributesSatisfyingExactly (
291- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
292- equalTo (CODE_FUNCTION , "completableFuture" ))));
299+ equalTo (
300+ CODE_FUNCTION_NAME ,
301+ TracedWithSpan .class .getName () + ".completableFuture" ))));
293302 }
294303
295304 @ Test
@@ -310,8 +319,9 @@ void completingCompletableFuture() throws Exception {
310319 .hasKind (SpanKind .INTERNAL )
311320 .hasNoParent ()
312321 .hasAttributesSatisfyingExactly (
313- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
314- equalTo (CODE_FUNCTION , "completableFuture" ))));
322+ equalTo (
323+ CODE_FUNCTION_NAME ,
324+ TracedWithSpan .class .getName () + ".completableFuture" ))));
315325 }
316326
317327 @ Test
@@ -333,8 +343,9 @@ void exceptionallyCompletingCompletableFuture() throws Exception {
333343 .hasNoParent ()
334344 .hasStatus (StatusData .error ())
335345 .hasAttributesSatisfying (
336- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
337- equalTo (CODE_FUNCTION , "completableFuture" ))));
346+ equalTo (
347+ CODE_FUNCTION_NAME ,
348+ TracedWithSpan .class .getName () + ".completableFuture" ))));
338349 }
339350
340351 @ Test
@@ -349,8 +360,9 @@ void captureAttributes() {
349360 .hasKind (SpanKind .INTERNAL )
350361 .hasNoParent ()
351362 .hasAttributesSatisfyingExactly (
352- equalTo (CODE_NAMESPACE , TracedWithSpan .class .getName ()),
353- equalTo (CODE_FUNCTION , "withSpanAttributes" ),
363+ equalTo (
364+ CODE_FUNCTION_NAME ,
365+ TracedWithSpan .class .getName () + ".withSpanAttributes" ),
354366 equalTo (stringKey ("implicitName" ), "foo" ),
355367 equalTo (stringKey ("explicitName" ), "bar" ))));
356368 }
@@ -399,8 +411,7 @@ public void run() {
399411 .hasKind (SpanKind .INTERNAL )
400412 .hasNoParent ()
401413 .hasAttributesSatisfyingExactly (
402- equalTo (CODE_NAMESPACE , "GeneratedJava6TestClass" ),
403- equalTo (CODE_FUNCTION , "run" )),
414+ equalTo (CODE_FUNCTION_NAME , TracedWithSpan .class .getName () + ".run" )),
404415 span ->
405416 span .hasName ("intercept" )
406417 .hasKind (SpanKind .INTERNAL )
0 commit comments