brave.propagation.StrictCurrentTraceContext Java Examples
The following examples show how to use
brave.propagation.StrictCurrentTraceContext.
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: ITRemote.java From brave with Apache License 2.0 | 6 votes |
protected ITRemote() { CurrentTraceContext.Builder currentTraceContextBuilder = currentTraceContextBuilder(); if (currentTraceContextBuilder instanceof StrictCurrentTraceContext.Builder) { currentTraceContext = currentTraceContextBuilder.build(); checkForLeakedScopes = (Closeable) currentTraceContext; } else { StrictScopeDecorator strictScopeDecorator = StrictScopeDecorator.create(); currentTraceContext = currentTraceContextBuilder .addScopeDecorator(strictScopeDecorator).build(); checkForLeakedScopes = strictScopeDecorator; } propagationFactory = BaggagePropagation.newFactoryBuilder(B3Propagation.FACTORY) .add(SingleBaggageField.newBuilder(BAGGAGE_FIELD) .addKeyName(BAGGAGE_FIELD_KEY) .build()).build(); tracing = tracingBuilder(Sampler.ALWAYS_SAMPLE).build(); }
Example #2
Source File: TracingTest.java From brave with Apache License 2.0 | 6 votes |
/** * This behavior could be problematic as downstream services may report spans based on propagated * sampled status, and be missing a parent when their parent tracer is in noop. */ @Test public void setNoop_dropsDataButDoesntAffectSampling() { try (Tracing tracing = Tracing.newBuilder() .currentTraceContext(StrictCurrentTraceContext.create()) .addSpanHandler(spans).build()) { ScopedSpan parent = tracing.tracer().startScopedSpan("parent"); tracing.setNoop(true); // a new child retains sampled from parent even in noop brave.Span child = tracing.tracer().newChild(parent.context()); assertThat(child.context().sampled()).isTrue(); assertThat(child.isNoop()).isTrue(); child.finish(); parent.finish(); // a new trace is sampled from even when noop brave.Span root = tracing.tracer().newTrace(); assertThat(root.context().sampled()).isTrue(); assertThat(root.isNoop()).isTrue(); root.finish(); } assertThat(spans).isEmpty(); }
Example #3
Source File: ITTracingChannelInterceptorTests.java From spring-cloud-sleuth with Apache License 2.0 | 4 votes |
@Bean StrictCurrentTraceContext currentTraceContext() { return StrictCurrentTraceContext.create(); }
Example #4
Source File: ITRemote.java From brave with Apache License 2.0 | 4 votes |
/** Subclass to override the builder. The result will have {@link StrictScopeDecorator} added */ protected CurrentTraceContext.Builder currentTraceContextBuilder() { return StrictCurrentTraceContext.newBuilder(); }