brave.propagation.StrictScopeDecorator Java Examples

The following examples show how to use brave.propagation.StrictScopeDecorator. 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: TraceFilterTests.java    From spring-cloud-sleuth with Apache License 2.0 6 votes vote down vote up
@Test
public void createsChildFromHeadersWhenJoinUnsupported() throws Exception {
	Tracing tracing = Tracing.newBuilder()
			.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
					.addScopeDecorator(StrictScopeDecorator.create()).build())
			.addSpanHandler(this.spans).supportsJoin(false).build();
	HttpTracing httpTracing = HttpTracing.create(tracing);
	this.request = builder().header("b3", "0000000000000014-000000000000000a")
			.buildRequest(new MockServletContext());

	TracingFilter.create(httpTracing).doFilter(this.request, this.response,
			this.filterChain);

	then(Tracing.current().tracer().currentSpan()).isNull();
	then(this.spans).hasSize(1);
	then(this.spans.get(0).parentId()).isEqualTo("000000000000000a");
}
 
Example #2
Source File: ITRemote.java    From brave with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: ZipkinSpanAspectTest.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Bean
Tracing tracing(Queue<Span> spans) {
  return Tracing.newBuilder()
      .currentTraceContext(
          ThreadLocalCurrentTraceContext.newBuilder().addScopeDecorator(StrictScopeDecorator.create()).build())
      .spanReporter(spans::add)
      .build();
}
 
Example #4
Source File: TraceFilterTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
private Filter neverSampleFilter() {
	Tracing tracing = Tracing.newBuilder()
			.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
					.addScopeDecorator(StrictScopeDecorator.create()).build())
			.addSpanHandler(this.spans).sampler(Sampler.NEVER_SAMPLE)
			.supportsJoin(false).build();
	HttpTracing httpTracing = HttpTracing.newBuilder(tracing)
			.clientParser(new HttpClientParser()).serverParser(new HttpServerParser())
			.serverSampler(
					new SkipPatternHttpServerSampler(() -> Pattern.compile("")))
			.build();
	return TracingFilter.create(httpTracing);
}
 
Example #5
Source File: BraveIntegrationTest.java    From armeria with Apache License 2.0 5 votes vote down vote up
private static Tracing newTracing(String name) {
    final CurrentTraceContext currentTraceContext =
            RequestContextCurrentTraceContext.builder()
                                             .nonRequestThread("nonrequest-")
                                             .addScopeDecorator(StrictScopeDecorator.create())
                                             .build();
    return Tracing.newBuilder()
                  .currentTraceContext(currentTraceContext)
                  .localServiceName(name)
                  .addSpanHandler(spanHandler)
                  .sampler(Sampler.ALWAYS_SAMPLE)
                  .build();
}