Search in sources :

Example 1 with BraveSpan

use of brave.opentracing.BraveSpan in project spring-cloud-sleuth by spring-cloud.

the class BraveTracerTest method implicitParentFromSpanManager_start.

@Test
public void implicitParentFromSpanManager_start() {
    try (Scope scopeA = opentracing.buildSpan("spanA").startActive(true)) {
        BraveSpan span = opentracing.buildSpan("spanB").start();
        assertThat(span.unwrap().context().parentId()).isEqualTo(getTraceContext(scopeA).spanId());
    }
}
Also used : BraveSpan(brave.opentracing.BraveSpan) SpanInScope(brave.Tracer.SpanInScope) Scope(io.opentracing.Scope) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with BraveSpan

use of brave.opentracing.BraveSpan in project spring-cloud-sleuth by spring-cloud.

the class BraveTracerTest method implicitParentFromSpanManager_start_ignoreActiveSpan.

@Test
public void implicitParentFromSpanManager_start_ignoreActiveSpan() {
    try (Scope scopeA = opentracing.buildSpan("spanA").startActive(true)) {
        BraveSpan span = opentracing.buildSpan("spanB").ignoreActiveSpan().start();
        assertThat(span.unwrap().context().parentId()).isNull();
    }
}
Also used : BraveSpan(brave.opentracing.BraveSpan) SpanInScope(brave.Tracer.SpanInScope) Scope(io.opentracing.Scope) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with BraveSpan

use of brave.opentracing.BraveSpan in project spring-cloud-sleuth by spring-cloud.

the class BraveTracerTest method injectTraceContext_baggage.

@Test
public void injectTraceContext_baggage() throws Exception {
    BraveSpan span = opentracing.buildSpan("foo").start();
    span.setBaggageItem("country-code", "FO");
    Map<String, String> map = new LinkedHashMap<>();
    TextMapInjectAdapter carrier = new TextMapInjectAdapter(map);
    opentracing.inject(span.context(), Format.Builtin.HTTP_HEADERS, carrier);
    assertThat(map).containsEntry("baggage-country-code", "FO");
}
Also used : BraveSpan(brave.opentracing.BraveSpan) TextMapInjectAdapter(io.opentracing.propagation.TextMapInjectAdapter) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with BraveSpan

use of brave.opentracing.BraveSpan in project spring-cloud-sleuth by spring-cloud.

the class BraveTracerTest method startWithOpenTracingAndFinishWithBrave.

@Test
public void startWithOpenTracingAndFinishWithBrave() {
    io.opentracing.Span openTracingSpan = opentracing.buildSpan("encode").withTag("lc", "codec").withStartTimestamp(1L).start();
    Span braveSpan = ((BraveSpan) openTracingSpan).unwrap();
    braveSpan.annotate(2L, "pump fake");
    braveSpan.finish(3L);
    checkSpanReportedToZipkin();
}
Also used : BraveSpan(brave.opentracing.BraveSpan) Span(brave.Span) BraveSpan(brave.opentracing.BraveSpan) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

BraveSpan (brave.opentracing.BraveSpan)4 Test (org.junit.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 SpanInScope (brave.Tracer.SpanInScope)2 Scope (io.opentracing.Scope)2 Span (brave.Span)1 TextMapInjectAdapter (io.opentracing.propagation.TextMapInjectAdapter)1 LinkedHashMap (java.util.LinkedHashMap)1