Search in sources :

Example 1 with AsyncReporter

use of zipkin2.reporter.AsyncReporter in project spring-cloud-gcp by spring-cloud.

the class StackdriverTraceAutoConfiguration method stackdriverReporter.

@Bean(REPORTER_BEAN_NAME)
@ConditionalOnMissingBean(name = REPORTER_BEAN_NAME)
public Reporter<Span> stackdriverReporter(ReporterMetrics reporterMetrics, GcpTraceProperties trace, @Qualifier(SENDER_BEAN_NAME) Sender sender) {
    AsyncReporter<Span> asyncReporter = AsyncReporter.builder(sender).queuedMaxSpans(1000).messageTimeout(trace.getMessageTimeout(), TimeUnit.SECONDS).metrics(reporterMetrics).build(StackdriverEncoder.V2);
    CheckResult checkResult = asyncReporter.check();
    if (!checkResult.ok()) {
        LOGGER.warn("Error when performing Stackdriver AsyncReporter health check.", checkResult.error());
    }
    return asyncReporter;
}
Also used : CheckResult(zipkin2.CheckResult) Span(zipkin2.Span) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with AsyncReporter

use of zipkin2.reporter.AsyncReporter in project spring-cloud-gcp by spring-cloud.

the class StackdriverTraceAutoConfigurationTests method testAsyncReporterHealthCheck.

@Test
public void testAsyncReporterHealthCheck() {
    Sender senderMock = mock(Sender.class);
    when(senderMock.check()).thenReturn(CheckResult.OK);
    when(senderMock.encoding()).thenReturn(SpanBytesEncoder.PROTO3.encoding());
    this.contextRunner.withBean(StackdriverTraceAutoConfiguration.SENDER_BEAN_NAME, Sender.class, () -> senderMock).run(context -> {
        Reporter<Span> asyncReporter = context.getBean(Reporter.class);
        assertThat(asyncReporter).isNotNull();
        verify(senderMock, times(1)).check();
    });
}
Also used : Sender(zipkin2.reporter.Sender) Span(com.google.devtools.cloudtrace.v2.Span) Test(org.junit.Test)

Aggregations

Span (com.google.devtools.cloudtrace.v2.Span)1 Test (org.junit.Test)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 CheckResult (zipkin2.CheckResult)1 Span (zipkin2.Span)1 Sender (zipkin2.reporter.Sender)1