use of io.opentelemetry.context.ContextStorage in project splunk-otel-java by signalfx.
the class JfrContextStorageTest method testCurrentSimplyDelegates.
@Test
void testCurrentSimplyDelegates() {
Context expected = mock(Context.class);
ContextStorage delegate = mock(ContextStorage.class);
when(delegate.current()).thenReturn(expected);
JfrContextStorage contextStorage = new JfrContextStorage(delegate);
Context result = contextStorage.current();
assertEquals(expected, result);
}
use of io.opentelemetry.context.ContextStorage in project opentelemetry-java-instrumentation by open-telemetry.
the class InstrumentationExtension method afterEach.
@Override
public void afterEach(ExtensionContext context) throws Exception {
ContextStorage storage = ContextStorage.get();
ContextStorageCloser.close(storage);
}
use of io.opentelemetry.context.ContextStorage in project splunk-otel-java by signalfx.
the class JfrContextStorageTest method testNotSampled.
@Test
void testNotSampled() {
Scope scope = mock(Scope.class);
ContextStorage delegate = mock(ContextStorage.class);
spanContext = SpanContext.create(traceId, spanId, TraceFlags.getDefault(), TraceState.getDefault());
span = Span.wrap(spanContext);
newContext = Context.root().with(span);
when(delegate.attach(newContext)).thenReturn(scope);
AtomicBoolean newEventWasCalled = new AtomicBoolean(false);
Function<SpanContext, ContextAttached> newEvent = x -> {
newEventWasCalled.set(true);
return null;
};
JfrContextStorage contextStorage = new JfrContextStorage(delegate, newEvent);
Scope result = contextStorage.attach(newContext);
assertEquals(scope, result);
assertFalse(newEventWasCalled.get());
}
Aggregations