zipkin2.reporter.Reporter Java Examples

The following examples show how to use zipkin2.reporter.Reporter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractBraveModuleTest.java    From crnk-framework with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public TestApplication() {
    property(CrnkProperties.RESOURCE_DEFAULT_DOMAIN, "http://test.local");

    serverReporter = Mockito.mock(Reporter.class);

    Tracing tracing = Tracing.newBuilder()
            .localServiceName("testServer")
            .spanReporter(serverReporter)
            .build();

    SimpleModule testModule = new SimpleModule("test");
    testModule.addRepository(new ProjectRepository());
    testModule.addRepository(new TaskRepository());
    testModule.addRepository(new TaskToProjectRepository());
    testModule.addRepository(new ProjectToTaskRepository());

    CrnkFeature feature = new CrnkFeature();
    feature.addModule(BraveServerModule.create(tracing));
    feature.addModule(testModule);
    register(feature);
}
 
Example #2
Source File: HttpClientBenchmarks.java    From brave with Apache License 2.0 6 votes vote down vote up
@Setup(Level.Trial) public void init() throws Exception {
  server = Undertow.builder()
    .addHttpListener(0, "127.0.0.1")
    .setHandler(exchange -> {
      exchange.getResponseHeaders().put(CONTENT_TYPE, "text/plain; charset=UTF-8");
      exchange.getResponseSender().send("hello world");
    }).build();
  server.start();
  baseUrl = "http://127.0.0.1:" +
    ((InetSocketAddress) server.getListenerInfo().get(0).getAddress()).getPort();

  client = newClient();
  tracedClient = newClient(HttpTracing.create(
    Tracing.newBuilder().spanReporter(Reporter.NOOP).build()
  ));
  unsampledClient = newClient(HttpTracing.create(
    Tracing.newBuilder().sampler(Sampler.NEVER_SAMPLE).spanReporter(Reporter.NOOP).build()
  ));
}
 
Example #3
Source File: WingtipsWithZipkinSpringBootConfiguration.java    From wingtips with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize configuration.
 * Add Zipkin listener if our {@link WingtipsZipkinProperties} indicates it has the necessary properties specified.
 */
private void init() {
    if (wingtipsZipkinProperties.shouldApplyWingtipsToZipkinLifecycleListener()) {
        Reporter<zipkin2.Span> zipkinSpanReporter = (zipkinReporterOverride != null)
            ? zipkinReporterOverride
            : WingtipsToZipkinLifecycleListener.generateBasicZipkinReporter(wingtipsZipkinProperties.getBaseUrl());

        WingtipsToZipkinSpanConverter zipkinSpanConverter = (zipkinSpanConverterOverride != null)
            ? zipkinSpanConverterOverride
            : new WingtipsToZipkinSpanConverterDefaultImpl();

        WingtipsToZipkinLifecycleListener listenerToRegister = new WingtipsToZipkinLifecycleListener(
            wingtipsZipkinProperties.getServiceName(),
            zipkinSpanConverter,
            zipkinSpanReporter
        );

        Tracer.getInstance().addSpanLifecycleListener(listenerToRegister);
    }
}
 
Example #4
Source File: TracingTest.java    From brave with Apache License 2.0 6 votes vote down vote up
@Test public void spanReporter_getsLocalEndpointInfo() {
  String expectedLocalServiceName = "favistar", expectedLocalIp = "1.2.3.4";
  int expectedLocalPort = 80;

  List<zipkin2.Span> zipkinSpans = new ArrayList<>();
  Reporter<zipkin2.Span> spanReporter = span -> {
    assertThat(span.localServiceName()).isEqualTo(expectedLocalServiceName);
    assertThat(span.localEndpoint().ipv4()).isEqualTo(expectedLocalIp);
    assertThat(span.localEndpoint().portAsInt()).isEqualTo(expectedLocalPort);
    zipkinSpans.add(span);
  };

  try (Tracing tracing = Tracing.newBuilder()
    .localServiceName(expectedLocalServiceName)
    .localIp(expectedLocalIp)
    .localPort(expectedLocalPort)
    .spanReporter(spanReporter)
    .build()) {
    tracing.tracer().newTrace().start().finish();
  }

  assertThat(zipkinSpans).isNotEmpty(); // ensures the assertions passed.
}
 
Example #5
Source File: WingtipsWithZipkinSpringBoot2WebfluxConfiguration.java    From wingtips with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize configuration.
 * Add Zipkin listener if our {@link WingtipsZipkinProperties} indicates it has the necessary properties specified.
 */
private void init() {
    if (wingtipsZipkinProperties.shouldApplyWingtipsToZipkinLifecycleListener()) {
        Reporter<zipkin2.Span> zipkinSpanReporter = (zipkinReporterOverride != null)
            ? zipkinReporterOverride
            : WingtipsToZipkinLifecycleListener.generateBasicZipkinReporter(wingtipsZipkinProperties.getBaseUrl());

        WingtipsToZipkinSpanConverter zipkinSpanConverter = (zipkinSpanConverterOverride != null)
            ? zipkinSpanConverterOverride
            : new WingtipsToZipkinSpanConverterDefaultImpl();

        WingtipsToZipkinLifecycleListener listenerToRegister = new WingtipsToZipkinLifecycleListener(
            wingtipsZipkinProperties.getServiceName(),
            zipkinSpanConverter,
            zipkinSpanReporter
        );

        Tracer.getInstance().addSpanLifecycleListener(listenerToRegister);
    }
}
 
Example #6
Source File: StackdriverTraceAutoConfigurationTests.java    From spring-cloud-gcp with Apache License 2.0 6 votes vote down vote up
@Test
public void testAsyncReporterHealthCheck() {
	Sender senderMock = mock(Sender.class);
	when(senderMock.check()).thenReturn(CheckResult.failed(new RuntimeException()));
	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();
			});
}
 
Example #7
Source File: StackdriverTraceAutoConfiguration.java    From spring-cloud-gcp with Apache License 2.0 6 votes vote down vote up
@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)
			// historical constraint. Note: AsyncReporter supports memory bounds
			.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;
}
 
Example #8
Source File: AbstractBraveModuleTest.java    From crnk-framework with Apache License 2.0 6 votes vote down vote up
@Before
@SuppressWarnings("unchecked")
public void setup() {
    Endpoint localEndpoint = Endpoint.newBuilder().serviceName("testClient").build();

    clientReporter = Mockito.mock(Reporter.class);
    Tracing clientTracing = Tracing.newBuilder()
            .spanReporter(clientReporter)
            .localEndpoint(localEndpoint)
            .build();

    client = new CrnkClient(getBaseUri().toString());
    client.setHttpAdapter(httpAdapter);
    client.addModule(BraveClientModule.create(clientTracing));
    taskRepo = client.getRepositoryForType(Task.class);
    TaskRepository.clear();
    ProjectRepository.clear();
    httpAdapter.setReceiveTimeout(10000, TimeUnit.SECONDS);
}
 
Example #9
Source File: TracingFactoryBean.java    From brave with Apache License 2.0 6 votes vote down vote up
@Override protected Tracing createInstance() {
  Tracing.Builder builder = Tracing.newBuilder();
  if (localServiceName != null) builder.localServiceName(localServiceName);
  if (localEndpoint == null) localEndpoint = endpoint;
  if (localEndpoint != null) {
    builder.endpoint((Endpoint) localEndpoint);
  }
  if (spanReporter != null) {
    builder.spanReporter((Reporter<Span>) spanReporter);
  }
  for (SpanHandler spanHandler : spanHandlers) {
    builder.addSpanHandler(spanHandler);
  }
  if (errorParser != null) builder.errorParser(errorParser);
  if (clock != null) builder.clock(clock);
  if (sampler != null) builder.sampler(sampler);
  if (currentTraceContext != null) builder.currentTraceContext(currentTraceContext);
  if (propagationFactory != null) builder.propagationFactory(propagationFactory);
  if (traceId128Bit != null) builder.traceId128Bit(traceId128Bit);
  if (supportsJoin != null) builder.supportsJoin(supportsJoin);
  if (customizers != null) {
    for (TracingCustomizer customizer : customizers) customizer.customize(builder);
  }
  return builder.build();
}
 
Example #10
Source File: OpenTracingUtil.java    From problematic-microservices with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void configureOpenTracing(Properties configuration, String serviceName) {
	Tracer tracer = null;
	String tracerName = configuration.getProperty("tracer");
	if ("jaeger".equals(tracerName)) {
		SamplerConfiguration samplerConfig = new SamplerConfiguration().withType(ConstSampler.TYPE).withParam(1);
		SenderConfiguration senderConfig = new SenderConfiguration()
				.withAgentHost(configuration.getProperty("jaeger.reporter.host"))
				.withAgentPort(Integer.decode(configuration.getProperty("jaeger.reporter.port")));
		ReporterConfiguration reporterConfig = new ReporterConfiguration().withLogSpans(true)
				.withFlushInterval(1000).withMaxQueueSize(10000).withSender(senderConfig);
		tracer = new Configuration(serviceName).withSampler(samplerConfig).withReporter(reporterConfig).getTracer();
	} else if ("zipkin".equals(tracerName)) {
		OkHttpSender sender = OkHttpSender.create("http://" + configuration.getProperty("zipkin.reporter.host")
				+ ":" + configuration.getProperty("zipkin.reporter.port") + "/api/v2/spans");
		Reporter<Span> reporter = AsyncReporter.builder(sender).build();
		tracer = BraveTracer
				.create(Tracing.newBuilder().localServiceName(serviceName).spanReporter(reporter).build());
	}
	GlobalTracer.register(new DelegatingJfrTracer(tracer));
}
 
Example #11
Source File: ZipkinTraceFactory.java    From pampas with Apache License 2.0 6 votes vote down vote up
@Override
public Tracer getTracer() {
    Sender sender = OkHttpSender.create("http://192.168.20.131:9411/api/v2/spans");

    Reporter spanReporter = AsyncReporter.create(sender);
    // If you want to support baggage, indicate the fields you'd like to
    // whitelist, in this case "country-code" and "user-id". On the wire,
    // they will be prefixed like "baggage-country-code"
    Propagation.Factory propagationFactory = ExtraFieldPropagation.newFactoryBuilder(B3Propagation.FACTORY)
            .addPrefixedFields("baggage-", Arrays.asList("country-code", "user-id"))
            .build();
    Tracing braveTracing = Tracing.newBuilder()
            .localServiceName("gateway")
            .propagationFactory(propagationFactory)
            .spanReporter(spanReporter)
            .build();
    Tracer tracer = BraveTracer.create(braveTracing);

    return tracer;
}
 
Example #12
Source File: ZipkinAutoConfiguration.java    From spring-cloud-sleuth with Apache License 2.0 6 votes vote down vote up
/** Returns one handler for as many reporters as exist. */
@Bean
SpanHandler zipkinSpanHandler(@Nullable List<Reporter<Span>> spanReporters,
		@Nullable Tag<Throwable> errorTag) {
	if (spanReporters == null) {
		return SpanHandler.NOOP;
	}

	LinkedHashSet<Reporter<Span>> reporters = new LinkedHashSet<>(spanReporters);
	reporters.remove(Reporter.NOOP);
	if (spanReporters.isEmpty()) {
		return SpanHandler.NOOP;
	}

	Reporter<Span> spanReporter = reporters.size() == 1 ? reporters.iterator().next()
			: new CompositeSpanReporter(reporters.toArray(new Reporter[0]));

	ZipkinSpanHandler.Builder builder = ZipkinSpanHandler.newBuilder(spanReporter);
	if (errorTag != null) {
		builder.errorTag(errorTag);
	}
	return builder.build();
}
 
Example #13
Source File: TracingProducerBenchmarks.java    From brave with Apache License 2.0 5 votes vote down vote up
@Setup(Level.Trial) public void init() {
  Tracing tracing = Tracing.newBuilder().spanReporter(Reporter.NOOP).build();
  producer = new FakeProducer();
  tracingProducer = KafkaTracing.create(tracing).producer(producer);
  tracingB3SingleProducer =
    KafkaTracing.newBuilder(tracing).writeB3SingleFormat(true).build().producer(producer);
}
 
Example #14
Source File: JerseyServerBenchmarks.java    From brave with Apache License 2.0 5 votes vote down vote up
@Override public Set<Object> getSingletons() {
  return new LinkedHashSet<>(asList(new Resource(), TracingApplicationEventListener.create(
    HttpTracing.create(Tracing.newBuilder()
      .propagationFactory(BaggagePropagation.newFactoryBuilder(B3Propagation.FACTORY)
        .add(SingleBaggageField.remote(BAGGAGE_FIELD)).build())
      .spanReporter(Reporter.NOOP)
      .build())
  )));
}
 
Example #15
Source File: WingtipsWithZipkinSpringBootConfigurationTest.java    From wingtips with Apache License 2.0 5 votes vote down vote up
ComponentTestSetup(Class<?> mainClass,
                   boolean expectComponentScannedObjects,
                   Reporter<Span> expectedReporterOverride,
                   WingtipsToZipkinSpanConverter expectedConverterOverride) {
    this.mainClass = mainClass;
    this.expectComponentScannedObjects = expectComponentScannedObjects;
    this.expectedReporterOverride = expectedReporterOverride;
    this.expectedConverterOverride = expectedConverterOverride;
}
 
Example #16
Source File: TracingConfiguration.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Bean
Reporter<Span> zipkinReporter(Sender sender) {
  if (apiVersion.compareTo(CONFIG_TRACING_COLLECTOR_API_V1) == 0) {
    return AsyncReporter.builder(sender).build(SpanBytesEncoder.JSON_V1);
  }

  return AsyncReporter.builder(sender).build();
}
 
Example #17
Source File: TracingMessagePostProcessorBenchmarks.java    From brave with Apache License 2.0 5 votes vote down vote up
@Setup(Level.Trial) public void init() {
  Tracing tracing = Tracing.newBuilder().spanReporter(Reporter.NOOP).build();
  tracingPostProcessor = new TracingMessagePostProcessor(SpringRabbitTracing.create(tracing));
  tracingB3SinglePostProcessor = new TracingMessagePostProcessor(
    SpringRabbitTracing.newBuilder(tracing).writeB3SingleFormat(true).build()
  );
}
 
Example #18
Source File: JerseyServerBenchmarks.java    From brave with Apache License 2.0 5 votes vote down vote up
@Override public Set<Object> getSingletons() {
  return new LinkedHashSet<>(asList(new Resource(), TracingApplicationEventListener.create(
    HttpTracing.create(Tracing.newBuilder()
      .sampler(Sampler.NEVER_SAMPLE)
      .spanReporter(Reporter.NOOP)
      .build())
  )));
}
 
Example #19
Source File: WingtipsWithZipkinSpringBoot2WebfluxConfigurationTest.java    From wingtips with Apache License 2.0 5 votes vote down vote up
ComponentTestSetup(Class<?> mainClass,
                   boolean expectComponentScannedObjects,
                   Reporter<Span> expectedReporterOverride,
                   WingtipsToZipkinSpanConverter expectedConverterOverride) {
    this.mainClass = mainClass;
    this.expectComponentScannedObjects = expectComponentScannedObjects;
    this.expectedReporterOverride = expectedReporterOverride;
    this.expectedConverterOverride = expectedConverterOverride;
}
 
Example #20
Source File: TracingConfiguration.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Bean
Tracing tracing(Reporter<Span> reporter, DynamicProperties dynamicProperties,
    CurrentTraceContext currentTraceContext) {
  return Tracing.newBuilder()
      .localServiceName(dynamicProperties.getStringProperty(CONFIG_QUALIFIED_MICROSERVICE_NAME_KEY,
          DEFAULT_MICROSERVICE_NAME))
      .currentTraceContext(currentTraceContext) // puts trace IDs into logs
      .spanReporter(reporter)
      .build();
}
 
Example #21
Source File: WingtipsToZipkinLifecycleListener.java    From wingtips with Apache License 2.0 5 votes vote down vote up
/**
 * @param postZipkinSpansBaseUrl The Zipkin base URL. This is everything except the endpoint path, i.e.
 * {@code http://foo.bar:9411}.
 * @return A new {@link AsyncReporter} that uses a basic {@link URLConnectionSender} for sending spans via HTTP to
 * the standard Zipkin {@code POST /api/v2/spans} endpoint.
 */
public static Reporter<zipkin2.Span> generateBasicZipkinReporter(String postZipkinSpansBaseUrl) {
    return AsyncReporter.create(
        URLConnectionSender.create(
            postZipkinSpansBaseUrl + (postZipkinSpansBaseUrl.endsWith("/") ? "" : "/") + "api/v2/spans"
        )
    );
}
 
Example #22
Source File: WingtipsToZipkinLifecycleListenerTest.java    From wingtips with Apache License 2.0 5 votes vote down vote up
@Before
@SuppressWarnings("unchecked")
public void beforeMethod() {
    serviceName = UUID.randomUUID().toString();
    spanConverterMock = mock(WingtipsToZipkinSpanConverter.class);
    spanReporterMock = mock(Reporter.class);

    listener = new WingtipsToZipkinLifecycleListener(serviceName, spanConverterMock, spanReporterMock);

    spanMock = mock(Span.class);
}
 
Example #23
Source File: TracingUtil.java    From oxd with Apache License 2.0 5 votes vote down vote up
private static Tracer createTracer(OxdServerConfiguration configuration, String componentName) {
    String tracerName = configuration.getTracer();

    if (!configuration.getEnableTracing() || Strings.isNullOrEmpty(tracerName)) {
        return NoopTracerFactory.create();
    } else if ("jaeger".equals(tracerName)) {
        Configuration.SamplerConfiguration samplerConfig = new Configuration.SamplerConfiguration()
                .withType(ConstSampler.TYPE)
                .withParam(1);

        Configuration.SenderConfiguration senderConfig = new Configuration.SenderConfiguration()
                .withAgentHost(configuration.getTracerHost())
                .withAgentPort(configuration.getTracerPort());

        Configuration.ReporterConfiguration reporterConfig = new Configuration.ReporterConfiguration()
                .withLogSpans(true)
                .withFlushInterval(1000)
                .withMaxQueueSize(10000)
                .withSender(senderConfig);

        return new Configuration(componentName)
                .withSampler(samplerConfig)
                .withReporter(reporterConfig)
                .getTracer();
    } else if ("zipkin".equals(tracerName)) {
        OkHttpSender sender = OkHttpSender.create(
                "http://" + configuration.getTracerHost() + ":" + configuration.getTracerPort() + "/api/v1/spans");

        Reporter<Span> reporter = AsyncReporter.builder(sender).build();

        return BraveTracer.create(Tracing.newBuilder()
                .localServiceName(componentName)
                .spanReporter(reporter)
                .build());
    } else {
        return NoopTracerFactory.create();
    }
}
 
Example #24
Source File: TracingFactoryBeanTest.java    From brave with Apache License 2.0 5 votes vote down vote up
@Test public void spanReporter() {
  context = new XmlBeans(""
    + "<bean id=\"tracing\" class=\"brave.spring.beans.TracingFactoryBean\">\n"
    + "  <property name=\"spanReporter\">\n"
    + "    <util:constant static-field=\"zipkin2.reporter.Reporter.CONSOLE\"/>\n"
    + "  </property>\n"
    + "</bean>"
  );

  assertThat(context.getBean("tracing", Tracing.class))
    .extracting("tracer.spanHandler.delegate.spanReporter.delegate")
    .isEqualTo(Reporter.CONSOLE);
}
 
Example #25
Source File: XioTracing.java    From xio with Apache License 2.0 5 votes vote down vote up
Reporter<Span> buildReporter(@NonNull String zipkinUrl) {
  OkHttpClient.Builder clientBuilder = OkHttpClientBuilderFactory.createZipkinClientBuilder();
  OkHttpSender sender =
      OkHttpSenderBuilderFactory.createSenderBuilder(clientBuilder)
          .encoding(Encoding.JSON)
          .endpoint(zipkinUrl)
          .compressionEnabled(false)
          .build();
  return AsyncReporter.builder(sender).build();
}
 
Example #26
Source File: ZipkinAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldOverrideDefaultBeans() {
	this.context = new AnnotationConfigApplicationContext();
	this.context.register(ZipkinAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class, TraceAutoConfiguration.class,
			Config.class, MyConfig.class);
	this.context.refresh();

	then(this.context.getBeansOfType(Sender.class)).hasSize(1);
	then(this.context.getBeansOfType(Sender.class))
			.containsKeys(ZipkinAutoConfiguration.SENDER_BEAN_NAME);

	then(this.context.getBeansOfType(Reporter.class)).hasSize(1);
	then(this.context.getBeansOfType(Reporter.class))
			.containsKeys(ZipkinAutoConfiguration.REPORTER_BEAN_NAME);

	Span span = this.context.getBean(Tracing.class).tracer().nextSpan().name("foo")
			.tag("foo", "bar").start();

	span.finish();

	Awaitility.await()
			.untilAsserted(() -> then(this.server.getRequestCount()).isEqualTo(0));

	MyConfig.MySender sender = this.context.getBean(MyConfig.MySender.class);
	Awaitility.await().untilAsserted(() -> then(sender.isSpanSent()).isTrue());
}
 
Example #27
Source File: ZipkinAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Test
public void supportsMultipleReporters() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	environment().setProperty("spring.zipkin.base-url",
			this.server.url("/").toString());
	this.context.register(ZipkinAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class, TraceAutoConfiguration.class,
			Config.class, MultipleReportersConfig.class);
	this.context.refresh();

	then(this.context.getBeansOfType(Sender.class)).hasSize(2);
	then(this.context.getBeansOfType(Sender.class))
			.containsKeys(ZipkinAutoConfiguration.SENDER_BEAN_NAME, "otherSender");

	then(this.context.getBeansOfType(Reporter.class)).hasSize(2);
	then(this.context.getBeansOfType(Reporter.class)).containsKeys(
			ZipkinAutoConfiguration.REPORTER_BEAN_NAME, "otherReporter");

	Span span = this.context.getBean(Tracing.class).tracer().nextSpan().name("foo")
			.tag("foo", "bar").start();

	span.finish();

	Awaitility.await().untilAsserted(
			() -> then(this.server.getRequestCount()).isGreaterThan(1));
	// first request is for health check
	this.server.takeRequest();
	// second request is the span one
	RecordedRequest request = this.server.takeRequest();
	then(request.getPath()).isEqualTo("/api/v2/spans");
	then(request.getBody().readUtf8()).contains("localEndpoint");

	MultipleReportersConfig.OtherSender sender = this.context
			.getBean(MultipleReportersConfig.OtherSender.class);
	Awaitility.await().untilAsserted(() -> then(sender.isSpanSent()).isTrue());
}
 
Example #28
Source File: ZipkinAutoConfiguration.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Override
public void report(Span span) {
	for (Reporter<Span> reporter : reporters) {
		try {
			reporter.report(span);
		}
		catch (RuntimeException ex) {
			// TODO: message lifted from ListReporter: this is probably too much
			// for warn level
			log.warn("Exception occurred while trying to report the span " + span,
					ex);
		}
	}
}
 
Example #29
Source File: ZipkinSpanHandlerFactoryBeanTest.java    From zipkin-reporter-java with Apache License 2.0 5 votes vote down vote up
@Test public void spanReporter() {
  context = new XmlBeans(""
      + "<bean id=\"zipkinSpanHandler\" class=\"zipkin2.reporter.beans.ZipkinSpanHandlerFactoryBean\">\n"
      + "  <property name=\"spanReporter\">\n"
      + "    <util:constant static-field=\"zipkin2.reporter.Reporter.CONSOLE\"/>\n"
      + "  </property>\n"
      + "</bean>"
  );

  assertThat(context.getBean("zipkinSpanHandler", ZipkinSpanHandler.class))
      .extracting("spanReporter.delegate")
      .isEqualTo(Reporter.CONSOLE);
}
 
Example #30
Source File: ZipkinAutoConfiguration.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Bean(REPORTER_BEAN_NAME)
@ConditionalOnMissingBean(name = REPORTER_BEAN_NAME)
public Reporter<Span> reporter(ReporterMetrics reporterMetrics,
		ZipkinProperties zipkin, @Qualifier(SENDER_BEAN_NAME) Sender sender) {
	CheckResult checkResult = checkResult(sender, 1_000L);
	logCheckResult(sender, checkResult);

	// historical constraint. Note: AsyncReporter supports memory bounds
	AsyncReporter<Span> asyncReporter = AsyncReporter.builder(sender)
			.queuedMaxSpans(1000)
			.messageTimeout(zipkin.getMessageTimeout(), TimeUnit.SECONDS)
			.metrics(reporterMetrics).build(zipkin.getEncoder());

	return asyncReporter;
}