Search in sources :

Example 1 with ContextHandle

use of io.opencensus.trace.ContextHandle in project instrumentation-java by census-instrumentation.

the class ContextUtilsTest method testGetCurrentSpan_ContextSetToNull.

@Test
public void testGetCurrentSpan_ContextSetToNull() {
    ContextHandle orig = ContextHandleUtils.withValue(ContextHandleUtils.currentContext(), null).attach();
    try {
        Span span = ContextHandleUtils.getValue(ContextHandleUtils.currentContext());
        // ContextUtils.getValue always returns non-null.
        assertThat(span).isEqualTo(BlankSpan.INSTANCE);
    } finally {
        ContextHandleUtils.currentContext().detach(orig);
    }
}
Also used : ContextHandle(io.opencensus.trace.ContextHandle) BlankSpan(io.opencensus.trace.BlankSpan) Span(io.opencensus.trace.Span) Test(org.junit.Test)

Aggregations

BlankSpan (io.opencensus.trace.BlankSpan)1 ContextHandle (io.opencensus.trace.ContextHandle)1 Span (io.opencensus.trace.Span)1 Test (org.junit.Test)1