Search in sources :

Example 1 with SleuthProperties

use of org.springframework.cloud.sleuth.autoconfig.SleuthProperties in project spring-cloud-gcp by spring-cloud.

the class StackdriverTraceAutoConfigurationTests method test.

@Test
public void test() {
    this.contextRunner.run(context -> {
        SleuthProperties sleuthProperties = context.getBean(SleuthProperties.class);
        assertThat(sleuthProperties.isTraceId128()).isTrue();
        assertThat(sleuthProperties.isSupportsJoin()).isFalse();
        Reporter<zipkin2.Span> reporter = context.getBean(Reporter.class);
        assertThat(reporter).isInstanceOf(StackdriverTraceReporter.class);
        Tracer tracer = context.getBean(Tracer.class);
        Span span = tracer.newTrace().start().kind(Span.Kind.CLIENT).name("test").start();
        span.finish();
        // There should be one trace received
        MockConfiguration configuration = context.getBean(MockConfiguration.class);
        assertThat(configuration.tracesList.size()).isEqualTo(1);
        Traces traces = configuration.tracesList.get(0);
        assertThat(traces.getTracesCount()).isEqualTo(1);
        Trace trace = traces.getTraces(0);
        assertThat(trace.getSpansCount()).isEqualTo(1);
        TraceSpan traceSpan = trace.getSpans(0);
    });
}
Also used : Trace(com.google.devtools.cloudtrace.v1.Trace) TraceSpan(com.google.devtools.cloudtrace.v1.TraceSpan) SleuthProperties(org.springframework.cloud.sleuth.autoconfig.SleuthProperties) Traces(com.google.devtools.cloudtrace.v1.Traces) Tracer(brave.Tracer) Span(brave.Span) TraceSpan(com.google.devtools.cloudtrace.v1.TraceSpan) Test(org.junit.Test)

Aggregations

Span (brave.Span)1 Tracer (brave.Tracer)1 Trace (com.google.devtools.cloudtrace.v1.Trace)1 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)1 Traces (com.google.devtools.cloudtrace.v1.Traces)1 Test (org.junit.Test)1 SleuthProperties (org.springframework.cloud.sleuth.autoconfig.SleuthProperties)1