Search in sources :

Example 1 with HttpServerParser

use of brave.http.HttpServerParser in project brave by openzipkin.

the class ITVertxWebTracing method handlesReroute.

void handlesReroute(String path) throws Exception {
    httpTracing = httpTracing.toBuilder().serverParser(new HttpServerParser() {

        @Override
        public <Req> void request(HttpAdapter<Req, ?> adapter, Req req, SpanCustomizer customizer) {
            super.request(adapter, req, customizer);
            // just the path is logged by default
            customizer.tag("http.url", adapter.url(req));
        }
    }).build();
    init();
    get(path);
    Span span = takeSpan();
    assertThat(span.tags()).containsEntry("http.path", path).containsEntry("http.url", url(path));
}
Also used : SpanCustomizer(brave.SpanCustomizer) Span(zipkin2.Span) HttpServerParser(brave.http.HttpServerParser)

Example 2 with HttpServerParser

use of brave.http.HttpServerParser in project brave by openzipkin.

the class ITTracingFeature_Container method declarative_namingPolicy.

@Test
public void declarative_namingPolicy() throws Exception {
    httpTracing = httpTracing.toBuilder().serverParser(new HttpServerParser() {

        @Override
        public <Req> String spanName(HttpAdapter<Req, ?> adapter, Req req) {
            Method method = ((ContainerAdapter) adapter).resourceMethod(req);
            return method.getName().toLowerCase();
        }
    }).build();
    init();
    get("/foo");
    Span span = takeSpan();
    assertThat(span.name()).isEqualTo("foo");
}
Also used : Method(java.lang.reflect.Method) Span(zipkin2.Span) HttpServerParser(brave.http.HttpServerParser) Test(org.junit.Test)

Example 3 with HttpServerParser

use of brave.http.HttpServerParser in project brave by openzipkin.

the class ITHttpServer method supportsPortableCustomization.

@Test
public void supportsPortableCustomization() throws Exception {
    httpTracing = httpTracing.toBuilder().serverParser(new HttpServerParser() {

        @Override
        public <Req> void request(HttpAdapter<Req, ?> adapter, Req req, SpanCustomizer customizer) {
            // just the path is logged by default
            customizer.tag("http.url", adapter.url(req));
            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");
}
Also used : SpanCustomizer(brave.SpanCustomizer) Span(zipkin2.Span) HttpServerParser(brave.http.HttpServerParser) Test(org.junit.Test)

Aggregations

HttpServerParser (brave.http.HttpServerParser)3 Span (zipkin2.Span)3 SpanCustomizer (brave.SpanCustomizer)2 Test (org.junit.Test)2 Method (java.lang.reflect.Method)1