Search in sources :

Example 16 with MutableSpan

use of brave.handler.MutableSpan in project brave by openzipkin.

the class ITHttpServer method childCompletesBeforeServer.

/**
 * The child completes before the response code is established, so it should be contained
 * completely by the server's interval.
 */
@Test
public void childCompletesBeforeServer() throws IOException {
    get("/child");
    MutableSpan child = testSpanHandler.takeLocalSpan();
    MutableSpan server = testSpanHandler.takeRemoteSpan(SERVER);
    assertChildOf(child, server);
    // sanity check
    assertThat(child.name()).isEqualTo("child");
    assertSpanInInterval(child, server.startTimestamp(), server.finishTimestamp());
}
Also used : MutableSpan(brave.handler.MutableSpan) Test(org.junit.Test)

Example 17 with MutableSpan

use of brave.handler.MutableSpan in project brave by openzipkin.

the class ITHttpServer method defaultSpanNameIsMethodNameOrRoute.

@Test
public void defaultSpanNameIsMethodNameOrRoute() throws IOException {
    get("/foo");
    MutableSpan span = testSpanHandler.takeRemoteSpan(SERVER);
    if (!span.name().equals("GET")) {
        assertThat(span.name()).isEqualTo("GET /foo");
    }
}
Also used : MutableSpan(brave.handler.MutableSpan) Test(org.junit.Test)

Example 18 with MutableSpan

use of brave.handler.MutableSpan in project brave by openzipkin.

the class ITHttpServer method httpStatusCodeTagMatchesResponse_onUncaughtException.

Response httpStatusCodeTagMatchesResponse_onUncaughtException(String path, String errorMessage) throws IOException {
    Response response = get(path);
    String responseCode = String.valueOf(response.code());
    MutableSpan span = testSpanHandler.takeRemoteSpanWithErrorMessage(SERVER, errorMessage);
    assertThat(span.tags()).containsEntry("http.status_code", responseCode);
    return response;
}
Also used : Response(okhttp3.Response) MutableSpan(brave.handler.MutableSpan)

Example 19 with MutableSpan

use of brave.handler.MutableSpan in project brave by openzipkin.

the class ITTracingFilter_Consumer method setError_onUnimplemented.

@Test
public void setError_onUnimplemented() {
    assertThatThrownBy(() -> wrongClient.get().sayHello("jorge")).isInstanceOf(RpcException.class);
    MutableSpan span = testSpanHandler.takeRemoteSpanWithErrorMessage(CLIENT, ".*Not found exported service.*");
    assertThat(span.tags()).containsEntry("dubbo.error_code", "1");
}
Also used : MutableSpan(brave.handler.MutableSpan) Test(org.junit.Test)

Example 20 with MutableSpan

use of brave.handler.MutableSpan in project brave by openzipkin.

the class ITTracingFilter_Consumer method setError_onUnimplemented_legacy.

/**
 * Shows if you aren't using RpcTracing, the old "dubbo.error_code" works
 */
@Test
public void setError_onUnimplemented_legacy() {
    ((TracingFilter) ExtensionLoader.getExtensionLoader(Filter.class).getExtension("tracing")).isInit = false;
    ((TracingFilter) ExtensionLoader.getExtensionLoader(Filter.class).getExtension("tracing")).setTracing(tracing);
    assertThatThrownBy(() -> wrongClient.get().sayHello("jorge")).isInstanceOf(RpcException.class);
    MutableSpan span = testSpanHandler.takeRemoteSpanWithErrorMessage(CLIENT, ".*Not found exported service.*");
    assertThat(span.tags()).containsEntry("dubbo.error_code", "1");
}
Also used : MutableSpan(brave.handler.MutableSpan) Filter(org.apache.dubbo.rpc.Filter) Test(org.junit.Test)

Aggregations

MutableSpan (brave.handler.MutableSpan)141 Test (org.junit.Test)107 TraceContext (brave.propagation.TraceContext)36 KafkaStreams (org.apache.kafka.streams.KafkaStreams)28 StreamsBuilder (org.apache.kafka.streams.StreamsBuilder)28 Topology (org.apache.kafka.streams.Topology)28 Scope (brave.propagation.CurrentTraceContext.Scope)14 ProcessorContext (org.apache.kafka.streams.processor.ProcessorContext)12 KeyValue (org.apache.kafka.streams.KeyValue)9 ArrayList (java.util.ArrayList)8 ProducerRecord (org.apache.kafka.clients.producer.ProducerRecord)8 MessagingTracing (brave.messaging.MessagingTracing)7 FileNotFoundException (java.io.FileNotFoundException)7 Arrays (java.util.Arrays)7 List (java.util.List)7 CONSUMER (brave.Span.Kind.CONSUMER)6 PRODUCER (brave.Span.Kind.PRODUCER)6 SpanHandler (brave.handler.SpanHandler)6 KafkaTracing (brave.kafka.clients.KafkaTracing)6 KAFKA_STREAMS_FILTERED_TAG (brave.kafka.streams.KafkaStreamsTags.KAFKA_STREAMS_FILTERED_TAG)6