Java Code Examples for io.opentracing.mock.MockTracer#buildSpan()

The following examples show how to use io.opentracing.mock.MockTracer#buildSpan() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpanBuilderWrapperTest.java    From java-jfr-tracer with Apache License 2.0 5 votes vote down vote up
@Test
void asChildOfOnParentSpanContext() {
    MockTracer delegateTracer = new MockTracer();
    Span parentSpan = delegateTracer.buildSpan("parentSpan").start();
    TracerWrapper tracerWrapper = new TracerWrapper(delegateTracer);
    String operationName = "asChildOfOnParentSpanContext";
    SpanBuilderWrapper spanBuilderWrapper = new SpanBuilderWrapper(tracerWrapper, operationName,
            delegateTracer.buildSpan(operationName));

    SpanBuilder spanBuilder = spanBuilderWrapper.asChildOf(parentSpan.context());
    assertSame(spanBuilderWrapper, spanBuilder);
    assertNotNull(spanBuilderWrapper.parentId());
    assertEquals(parentSpan.context().toSpanId(), spanBuilderWrapper.parentId());
}
 
Example 2
Source File: SpanBuilderWrapperTest.java    From java-jfr-tracer with Apache License 2.0 5 votes vote down vote up
@Test
void asChildOfOnParentSpanContextNull() {
    MockTracer delegateTracer = new MockTracer();
    TracerWrapper tracerWrapper = new TracerWrapper(delegateTracer);
    String operationName = "asChildOfOnParentSpanContextNull";
    SpanBuilderWrapper spanBuilderWrapper = new SpanBuilderWrapper(tracerWrapper, operationName,
            delegateTracer.buildSpan(operationName));

    SpanBuilder spanBuilder = spanBuilderWrapper.asChildOf((SpanContext) null);
    assertSame(spanBuilderWrapper, spanBuilder);
    assertNull(spanBuilderWrapper.parentId());
}
 
Example 3
Source File: SpanBuilderWrapperTest.java    From java-jfr-tracer with Apache License 2.0 5 votes vote down vote up
@Test
void asChildOfOnParentSpan() {
    MockTracer delegateTracer = new MockTracer();
    Span parentSpan = delegateTracer.buildSpan("parentSpan").start();
    TracerWrapper tracerWrapper = new TracerWrapper(delegateTracer);
    String operationName = "asChildOfOnParentSpan";
    SpanBuilderWrapper spanBuilderWrapper = new SpanBuilderWrapper(tracerWrapper, operationName,
            delegateTracer.buildSpan(operationName));

    SpanBuilder spanBuilder = spanBuilderWrapper.asChildOf(parentSpan);
    assertSame(spanBuilderWrapper, spanBuilder);
    assertNotNull(spanBuilderWrapper.parentId());
    assertEquals(parentSpan.context().toSpanId(), spanBuilderWrapper.parentId());
}
 
Example 4
Source File: SpanBuilderWrapperTest.java    From java-jfr-tracer with Apache License 2.0 5 votes vote down vote up
@Test
void asChildOfOnParentSpanNull() {
    MockTracer delegateTracer = new MockTracer();
    TracerWrapper tracerWrapper = new TracerWrapper(delegateTracer);
    String operationName = "asChildOfOnParentSpanNull";
    SpanBuilderWrapper spanBuilderWrapper = new SpanBuilderWrapper(tracerWrapper, operationName,
            delegateTracer.buildSpan(operationName));

    SpanBuilder spanBuilder = spanBuilderWrapper.asChildOf((Span) null);
    assertSame(spanBuilderWrapper, spanBuilder);
    assertNull(spanBuilderWrapper.parentId());
}
 
Example 5
Source File: SpanBuilderWrapperTest.java    From java-jfr-tracer with Apache License 2.0 5 votes vote down vote up
@Test
void addReferenceOnParentSpanContext() {
    MockTracer delegateTracer = new MockTracer();
    Span parentSpan = delegateTracer.buildSpan("parentSpan").start();
    TracerWrapper tracerWrapper = new TracerWrapper(delegateTracer);
    String operationName = "addReferenceOnParentSpanContext";
    SpanBuilderWrapper spanBuilderWrapper = new SpanBuilderWrapper(tracerWrapper, operationName,
            delegateTracer.buildSpan(operationName));

    SpanBuilder spanBuilder = spanBuilderWrapper.addReference(References.CHILD_OF, parentSpan.context());
    assertSame(spanBuilderWrapper, spanBuilder);
    assertNotNull(spanBuilderWrapper.parentId());
    assertEquals(parentSpan.context().toSpanId(), spanBuilderWrapper.parentId());
}
 
Example 6
Source File: SpanBuilderWrapperTest.java    From java-jfr-tracer with Apache License 2.0 5 votes vote down vote up
@Test
void addReferenceOnParentSpanContextNull() {
    MockTracer delegateTracer = new MockTracer();
    TracerWrapper tracerWrapper = new TracerWrapper(delegateTracer);
    String operationName = "addReferenceOnParentSpanContextNull";
    SpanBuilderWrapper spanBuilderWrapper = new SpanBuilderWrapper(tracerWrapper, operationName,
            delegateTracer.buildSpan(operationName));

    SpanBuilder spanBuilder = spanBuilderWrapper.addReference(References.CHILD_OF, null);
    assertSame(spanBuilderWrapper, spanBuilder);
    assertNull(spanBuilderWrapper.parentId());
}