Search in sources :

Example 21 with Span

use of io.opencensus.proto.trace.v1.Span in project brave by openzipkin.

the class ITHttpServer method reportsClientAddress.

@Test
public void reportsClientAddress() throws Exception {
    get("/foo");
    Span span = takeSpan();
    assertThat(span.remoteEndpoint()).isNotNull();
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 22 with Span

use of io.opencensus.proto.trace.v1.Span in project brave by openzipkin.

the class ITHttpServer method addsErrorTagOnException.

private void addsErrorTagOnException(String path) throws Exception {
    Span span = reportsSpanOnException(path);
    assertThat(span.tags()).containsKey("error");
}
Also used : Span(zipkin2.Span)

Example 23 with Span

use of io.opencensus.proto.trace.v1.Span in project brave by openzipkin.

the class ITHttpServer method addsStatusCode_badRequest.

@Test
public void addsStatusCode_badRequest() throws Exception {
    try {
        get("/badrequest");
    } catch (RuntimeException e) {
    // some servers think 400 is an error
    }
    Span span = takeSpan();
    assertThat(span.tags()).containsEntry("http.status_code", "400").containsEntry("error", "400");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 24 with Span

use of io.opencensus.proto.trace.v1.Span in project brave by openzipkin.

the class ITServlet25Container method canUseSpanAttribute.

/**
 * Shows that a framework can directly use the "brave.Span" rather than relying on the
 * current span.
 */
@Test
public void canUseSpanAttribute() throws Exception {
    delegate = customHook;
    get("/foo");
    Span span = takeSpan();
    assertThat(span.tags()).containsEntry("foo", "bar");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 25 with Span

use of io.opencensus.proto.trace.v1.Span 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)

Aggregations

Span (zipkin2.Span)290 Test (org.junit.Test)192 Test (org.junit.jupiter.api.Test)67 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)41 Endpoint (zipkin2.Endpoint)37 ArrayList (java.util.ArrayList)24 V1Span (zipkin2.v1.V1Span)17 List (java.util.List)14 AggregateCall (zipkin2.internal.AggregateCall)13 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)12 Arrays.asList (java.util.Arrays.asList)9 Map (java.util.Map)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 Span (com.google.devtools.cloudtrace.v2.Span)8 LinkedHashMap (java.util.LinkedHashMap)8 Trace (com.google.devtools.cloudtrace.v1.Trace)7 Span (zipkin2.proto3.Span)7 SpanData (io.opencensus.trace.export.SpanData)6 SpanCustomizer (brave.SpanCustomizer)5 IOException (java.io.IOException)5