Search in sources :

Example 26 with TraceContextOrSamplingFlags

use of brave.propagation.TraceContextOrSamplingFlags in project brave by openzipkin.

the class TracerTest method nextSpan_extractedTraceId_extra.

@Test
public void nextSpan_extractedTraceId_extra() {
    TraceIdContext traceIdContext = TraceIdContext.newBuilder().traceId(1L).build();
    TraceContextOrSamplingFlags extracted = TraceContextOrSamplingFlags.create(traceIdContext).toBuilder().addExtra(1L).build();
    assertThat(tracer.nextSpan(extracted).context().extra()).containsExactly(1L);
}
Also used : TraceIdContext(brave.propagation.TraceIdContext) TraceContextOrSamplingFlags(brave.propagation.TraceContextOrSamplingFlags) Test(org.junit.Test)

Example 27 with TraceContextOrSamplingFlags

use of brave.propagation.TraceContextOrSamplingFlags in project brave by openzipkin.

the class BraveTracer method extract.

@Override
public <C> BraveSpanContext extract(Format<C> format, C carrier) {
    if (format != Format.Builtin.HTTP_HEADERS) {
        throw new UnsupportedOperationException(format.toString());
    }
    TraceContextOrSamplingFlags extracted = extractor.extract(new TextMapView(propagationKeys, (TextMap) carrier));
    TraceContext context = extracted.context() != null ? tracer.joinSpan(extracted.context()).context() : tracer.nextSpan(extracted).context();
    return new BraveSpanContext(context);
}
Also used : TraceContext(brave.propagation.TraceContext) TextMap(io.opentracing.propagation.TextMap) TraceContextOrSamplingFlags(brave.propagation.TraceContextOrSamplingFlags)

Aggregations

TraceContextOrSamplingFlags (brave.propagation.TraceContextOrSamplingFlags)27 Test (org.junit.Test)13 Span (brave.Span)10 ThreadLocalSpan (brave.propagation.ThreadLocalSpan)4 TraceContext (brave.propagation.TraceContext)4 MessageHeaderAccessor (org.springframework.messaging.support.MessageHeaderAccessor)4 StrictCurrentTraceContext (brave.propagation.StrictCurrentTraceContext)3 GenericMessage (org.springframework.messaging.support.GenericMessage)3 Tracer (brave.Tracer)2 TraceIdContext (brave.propagation.TraceIdContext)2 LinkedHashMap (java.util.LinkedHashMap)2 Endpoint (zipkin2.Endpoint)2 Kind (brave.Span.Kind)1 SpanInScope (brave.Tracer.SpanInScope)1 Result (com.alibaba.dubbo.rpc.Result)1 RpcContext (com.alibaba.dubbo.rpc.RpcContext)1 FutureAdapter (com.alibaba.dubbo.rpc.protocol.dubbo.FutureAdapter)1 SimpleForwardingServerCall (io.grpc.ForwardingServerCall.SimpleForwardingServerCall)1 ServerCall (io.grpc.ServerCall)1 TextMap (io.opentracing.propagation.TextMap)1