-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the http.route attribute even for not sampled server spans (op…
- Loading branch information
Showing
4 changed files
with
54 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...test/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpRouteHolderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.instrumenter.http; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.trace.Span; | ||
import io.opentelemetry.api.trace.SpanContext; | ||
import io.opentelemetry.api.trace.TraceFlags; | ||
import io.opentelemetry.api.trace.TraceState; | ||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.instrumentation.api.internal.SpanKey; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class HttpRouteHolderTest { | ||
|
||
@Test | ||
void shouldSetRouteEvenIfSpanIsNotSampled() { | ||
Span span = | ||
Span.wrap( | ||
SpanContext.create( | ||
"00000000000000000000000000000042", | ||
"0000000000000012", | ||
TraceFlags.getDefault(), | ||
TraceState.getDefault())); | ||
|
||
Context context = Context.root(); | ||
context = context.with(span); | ||
context = SpanKey.SERVER.storeInContext(context, span); | ||
context = HttpRouteHolder.get().start(context, null, Attributes.empty()); | ||
|
||
assertNull(HttpRouteHolder.getRoute(context)); | ||
|
||
HttpRouteHolder.updateHttpRoute(context, HttpRouteSource.SERVLET, "/get/:id"); | ||
|
||
assertEquals("/get/:id", HttpRouteHolder.getRoute(context)); | ||
} | ||
|
||
// TODO(mateusz): add more unit tests for HttpRouteHolder | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters