use of io.opentelemetry.context.ContextKey in project opentelemetry-java-instrumentation by open-telemetry.
the class InstrumenterTest method shouldUseContextCustomizer.
@Test
void shouldUseContextCustomizer() {
// given
ContextKey<String> testKey = ContextKey.named("test");
Instrumenter<String, String> instrumenter = Instrumenter.<String, String>builder(otelTesting.getOpenTelemetry(), "test", request -> "test span").addContextCustomizer((context, request, attributes) -> context.with(testKey, "testVal")).newInstrumenter();
// when
Context context = instrumenter.start(Context.root(), "request");
// then
assertThat(context.get(testKey)).isEqualTo("testVal");
}
Aggregations