use of brave.http.HttpTracing in project brave by openzipkin.
the class DelegatingTracingFilter method init.
@Override
public void init(FilterConfig filterConfig) {
ApplicationContext ctx = getRequiredWebApplicationContext(filterConfig.getServletContext());
HttpTracing httpTracing = WebMvcRuntime.get().httpTracing(ctx);
delegate = TracingFilter.create(httpTracing);
}
use of brave.http.HttpTracing in project brave by openzipkin.
the class WebMvcRuntimeTest method WebMvc25_httpTracing_byName.
/**
* Spring 2.5 cannot get beans by type, so fallback to name
*/
@Test
public void WebMvc25_httpTracing_byName() {
ApplicationContext context = mock(ApplicationContext.class);
when(context.containsBean("httpTracing")).thenReturn(true);
when(context.getBean("httpTracing")).thenReturn(mock(HttpTracing.class));
new WebMvc25().httpTracing(context);
verify(context).containsBean("httpTracing");
verify(context).getBean("httpTracing");
verifyNoMoreInteractions(context);
}
use of brave.http.HttpTracing in project spring-cloud-sleuth by spring-cloud.
the class TraceFilterTests method createsChildFromHeadersWhenJoinUnsupported.
@Test
public void createsChildFromHeadersWhenJoinUnsupported() throws Exception {
Tracing tracing = Tracing.newBuilder().currentTraceContext(CurrentTraceContext.Default.create()).spanReporter(this.reporter).supportsJoin(false).build();
HttpTracing httpTracing = HttpTracing.create(tracing);
this.request = builder().header(SPAN_ID_NAME, PARENT_ID).header(TRACE_ID_NAME, SpanUtil.idToHex(20L)).buildRequest(new MockServletContext());
TracingFilter.create(httpTracing).doFilter(this.request, this.response, this.filterChain);
then(Tracing.current().tracer().currentSpan()).isNull();
then(this.reporter.getSpans()).hasSize(1);
then(this.reporter.getSpans().get(0).parentId()).isEqualTo(PARENT_ID);
}
use of brave.http.HttpTracing in project spring-cloud-sleuth by spring-cloud.
the class TraceFilterTests method neverSampleFilter.
private Filter neverSampleFilter() {
Tracing tracing = Tracing.newBuilder().currentTraceContext(CurrentTraceContext.Default.create()).spanReporter(this.reporter).sampler(Sampler.NEVER_SAMPLE).supportsJoin(false).build();
HttpTracing httpTracing = HttpTracing.newBuilder(tracing).clientParser(new SleuthHttpClientParser(this.traceKeys)).serverParser(new SleuthHttpServerParser(this.traceKeys, new ExceptionMessageErrorParser())).serverSampler(new SleuthHttpSampler(() -> Pattern.compile(""))).build();
return TracingFilter.create(httpTracing);
}
use of brave.http.HttpTracing in project zipkin by openzipkin.
the class ZipkinElasticsearchStorageConfiguration method esTracing.
@Bean
@Qualifier(QUALIFIER)
@ConditionalOnSelfTracing
Consumer<ClientOptionsBuilder> esTracing(Optional<HttpTracing> maybeHttpTracing) {
if (!maybeHttpTracing.isPresent()) {
// Alternatively, check why we would ever get here if ConditionalOnSelfTracing matches
return client -> {
};
}
HttpTracing httpTracing = maybeHttpTracing.get().clientOf("elasticsearch");
SpanCustomizer spanCustomizer = CurrentSpanCustomizer.create(httpTracing.tracing());
return client -> {
client.decorator((delegate, ctx, req) -> {
// We only need the name if it's available and can unsafely access the partially filled log.
RequestLog log = ctx.log().partial();
if (log.isAvailable(RequestLogProperty.NAME)) {
String name = log.name();
if (name != null) {
// override the span name if set
spanCustomizer.name(name);
}
}
return delegate.execute(ctx, req);
});
// the tracing decorator is added last so that it encloses the attempt to overwrite the name.
client.decorator(BraveClient.newDecorator(httpTracing));
};
}
Aggregations