brave.context.log4j2.ThreadContextScopeDecorator Java Examples

The following examples show how to use brave.context.log4j2.ThreadContextScopeDecorator. 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: TracingConfiguration.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
/** Controls aspects of tracing such as the service name that shows up in the UI */
@Bean
Tracing tracing(@Value("${zipkin.service:brave-webmvc-example}") String serviceName) {
    return Tracing.newBuilder()
        .localServiceName(serviceName)
        .propagationFactory(ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, "user-name"))
        .currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
            .addScopeDecorator(ThreadContextScopeDecorator.create()) // puts trace IDs into logs
            .build()
        )
        .spanReporter(spanReporter()).build();
}
 
Example #2
Source File: EndToEndBenchmarks.java    From brave with Apache License 2.0 5 votes vote down vote up
public TracedCorrelated() {
  super(Tracing.newBuilder()
    .currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
      // intentionally added twice to test overhead of multiple correlations
      .addScopeDecorator(ThreadContextScopeDecorator.get())
      .addScopeDecorator(ThreadContextScopeDecorator.get())
      .build())
    .addSpanHandler(new SpanHandler() {
      // intentionally not NOOP to ensure spans report
    })
    .build());
}
 
Example #3
Source File: TracingConfiguration.java    From brave-webmvc-example with MIT License 4 votes vote down vote up
/** Allows log patterns to use {@code %{traceId}} {@code %{spanId}} and {@code %{userName}} */
@Bean ScopeDecorator correlationScopeDecorator() {
  return ThreadContextScopeDecorator.newBuilder()
      .add(SingleCorrelationField.create(USER_NAME)).build();
}