@Bean @ConditionalOnMissingBean // NOTE: stable bean name as might be used outside sleuth HttpTracing httpTracing(Tracing tracing, SkipPatternProvider provider, HttpClientParser clientParser, HttpServerParser serverParser, @ClientSampler HttpSampler clientSampler, @Nullable @ServerSampler HttpSampler serverSampler) { HttpSampler combinedSampler = combineUserProvidedSamplerWithSkipPatternSampler( serverSampler, provider); return HttpTracing.newBuilder(tracing).clientParser(clientParser) .serverParser(serverParser).clientSampler(clientSampler) .serverSampler(combinedSampler).build(); }
@Test public void supportsPortableCustomization() throws Exception { httpTracing = httpTracing.toBuilder().serverParser(new HttpServerParser() { @Override public <Req> void request(HttpAdapter<Req, ?> adapter, Req req, SpanCustomizer customizer) { customizer.tag("http.url", adapter.url(req)); // just the path is logged by default customizer.tag("context.visible", String.valueOf(currentTraceContext.get() != null)); customizer.tag("request_customizer.is_span", (customizer instanceof brave.Span) + ""); } @Override public <Resp> void response(HttpAdapter<?, Resp> adapter, Resp res, Throwable error, SpanCustomizer customizer) { super.response(adapter, res, error, customizer); customizer.tag("response_customizer.is_span", (customizer instanceof brave.Span) + ""); } }).build(); init(); String uri = "/foo?z=2&yAA=1"; get(uri); Span span = takeSpan(); assertThat(span.tags()) .containsEntry("http.url", url(uri)) .containsEntry("context.visible", "true") .containsEntry("request_customizer.is_span", "false") .containsEntry("response_customizer.is_span", "false"); }
@Bean @ConditionalOnMissingBean // NOTE: stable bean name as might be used outside sleuth HttpTracing httpTracing(Tracing tracing, SkipPatternProvider provider) { HttpSampler serverSampler = combineUserProvidedSamplerWithSkipPatternSampler( provider); return HttpTracing.newBuilder(tracing).clientParser(this.clientParser) .serverParser(this.serverParser).clientSampler(this.clientSampler) .serverSampler(serverSampler).build(); }
@Test public void supportsPortableCustomization() throws Exception { httpTracing = httpTracing.toBuilder().serverParser(new HttpServerParser() { @Override public <Req> void request(HttpAdapter<Req, ?> adapter, Req req, SpanCustomizer customizer) { customizer.tag("http.url", adapter.url(req)); // just the path is logged by default customizer.tag("context.visible", String.valueOf(currentTraceContext.get() != null)); customizer.tag("request_customizer.is_span", (customizer instanceof brave.Span) + ""); } @Override public <Resp> void response(HttpAdapter<?, Resp> adapter, Resp res, Throwable error, SpanCustomizer customizer) { super.response(adapter, res, error, customizer); customizer.tag("response_customizer.is_span", (customizer instanceof brave.Span) + ""); } }).build(); init(); String uri = "/foo?z=2&yAA=1"; get(uri); Span span = takeSpan(); assertThat(span.tags()) .containsEntry("http.url", url(uri)) .containsEntry("context.visible", "true") .containsEntry("request_customizer.is_span", "false") .containsEntry("response_customizer.is_span", "false"); }
public BraveFeature(final String name) { this( HttpTracing .newBuilder(Tracing.newBuilder().localServiceName(name).build()) .serverParser(new HttpServerSpanParser()) .build() ); }
public BraveFeature(final Tracing tracing) { this( HttpTracing .newBuilder(tracing) .serverParser(new HttpServerSpanParser()) .build() ); }
/** * The "/items/{itemId}" endpoint should return the itemId in the response body, which proves * templating worked (including that it ignores query parameters). Note the route format is * framework specific, ex "/items/:itemId" in vert.x */ @Test public void httpRoute() throws Exception { httpTracing = httpTracing.toBuilder().serverParser(addHttpUrlTag).build(); init(); routeBasedRequestNameIncludesPathPrefix("/items"); }
/** * Sometimes state used to carry http route data is different for async requests. This helps * ensure we don't miss issues like this. */ @Test public void httpRoute_async() throws Exception { httpTracing = httpTracing.toBuilder().serverParser(addHttpUrlTag).build(); init(); routeBasedRequestNameIncludesPathPrefix("/async_items"); }
public BraveFeature(final Tracing tracing) { this( HttpTracing .newBuilder(tracing) .serverParser(new HttpServerSpanParser()) .build() ); }
public BraveFeature(final String name) { this( HttpTracing .newBuilder(Tracing.newBuilder().localServiceName(name).build()) .serverParser(new HttpServerSpanParser()) .build() ); }
@Override public HttpTracing getObject() { HttpTracing.Builder builder = HttpTracing.newBuilder(tracing); if (clientParser != null) builder.clientParser(clientParser); if (serverParser != null) builder.serverParser(serverParser); if (clientSampler != null) builder.clientSampler(clientSampler); if (serverSampler != null) builder.serverSampler(serverSampler); return builder.build(); }
/** * The "/nested/items/{itemId}" endpoint should be implemented by two route expressions: * A path prefix: "/nested" and then a relative expression "/items/{itemId}" */ @Test public void httpRoute_nested() throws Exception { httpTracing = httpTracing.toBuilder().serverParser(addHttpUrlTag).build(); init(); routeBasedRequestNameIncludesPathPrefix("/nested/items"); }
public BraveFeature(final Tracing tracing) { this( HttpTracing .newBuilder(tracing) .serverParser(new HttpServerSpanParser()) .build() ); }
public BraveFeature(final String name) { this( HttpTracing .newBuilder(Tracing.newBuilder().localServiceName(name).build()) .serverParser(new HttpServerSpanParser()) .build() ); }
public BraveFeature(final Tracing tracing) { this( HttpTracing .newBuilder(tracing) .serverParser(new HttpServerSpanParser()) .build() ); }
public BraveFeature(final String name) { this( HttpTracing .newBuilder(Tracing.newBuilder().localServiceName(name).build()) .serverParser(new HttpServerSpanParser()) .build() ); }
/** * The "/items/{itemId}" endpoint should return the itemId in the response body, which proves * templating worked (including that it ignores query parameters). Note the route format is * framework specific, ex "/items/:itemId" in vert.x */ @Test public void httpRoute() throws Exception { httpTracing = httpTracing.toBuilder().serverParser(addHttpUrlTag).build(); init(); routeBasedRequestNameIncludesPathPrefix("/items"); }
/** * Sometimes state used to carry http route data is different for async requests. This helps * ensure we don't miss issues like this. */ @Test public void httpRoute_async() throws Exception { httpTracing = httpTracing.toBuilder().serverParser(addHttpUrlTag).build(); init(); routeBasedRequestNameIncludesPathPrefix("/async_items"); }
/** * The "/nested/items/{itemId}" endpoint should be implemented by two route expressions: * A path prefix: "/nested" and then a relative expression "/items/{itemId}" */ @Test public void httpRoute_nested() throws Exception { httpTracing = httpTracing.toBuilder().serverParser(addHttpUrlTag).build(); init(); routeBasedRequestNameIncludesPathPrefix("/nested/items"); }
@Override public HttpTracing getObject() { HttpTracing.Builder builder = HttpTracing.newBuilder(tracing); if (clientParser != null) builder.clientParser(clientParser); if (serverParser != null) builder.serverParser(serverParser); if (clientSampler != null) builder.clientSampler(clientSampler); if (serverSampler != null) builder.serverSampler(serverSampler); return builder.build(); }