Created
March 26, 2024 17:47
-
-
Save breedx-splk/e4f5775a348e3a37c6dac71f719fa395 to your computer and use it in GitHub Desktop.
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
@Test | |
void testThing(){ | |
// You probably want to do this in setup? | |
OpenTelemetry otel = OpenTelemetrySdk.builder().build(); | |
SpanBuilder builder = otel.getTracer("foo") | |
.spanBuilder("span"); | |
Span span = builder.startSpan(); | |
try (Scope scope = span.makeCurrent()) { | |
{ // This would be your method under test | |
span.setAttribute("jim", "bob"); | |
} | |
String value = ((SdkSpan) span).toSpanData().getAttributes().get(stringKey("jim")); | |
assertThat(value).isEqualTo("bob"); | |
} | |
finally { | |
span.end(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment