brave.handler.FinishedSpanHandler Java Examples
The following examples show how to use
brave.handler.FinishedSpanHandler.
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: ZipkinSpanReporterConfig.java From brewery with Apache License 2.0 | 5 votes |
@Bean FinishedSpanHandler loggingSpanAdjuster() { return new FinishedSpanHandler() { @Override public boolean handle(TraceContext context, MutableSpan span) { log.info("Will report span [{}] to zipkin", span); return true; } }; }
Example #2
Source File: TracingTest.java From brave with Apache License 2.0 | 5 votes |
/** * This ensures deprecated overloads of {@link FinishedSpanHandler#alwaysSampleLocal()} are * considered. */ @Test public void finishedSpanHandler_affectsAlwaysSampleLocal() { FinishedSpanHandler one = mock(FinishedSpanHandler.class); when(one.alwaysSampleLocal()).thenReturn(false); FinishedSpanHandler two = mock(FinishedSpanHandler.class); when(two.alwaysSampleLocal()).thenReturn(true); try (Tracing tracing = Tracing.newBuilder() .addSpanHandler(one) .addSpanHandler(two) .build()) { assertThat(tracing.tracer().alwaysSampleLocal).isTrue(); } }
Example #3
Source File: Tracing.java From brave with Apache License 2.0 | 4 votes |
Default(Builder builder) { this.clock = builder.clock != null ? builder.clock : Platform.get().clock(); this.errorParser = builder.errorParser; this.propagationFactory = builder.propagationFactory; this.stringPropagation = builder.propagationFactory.get(); this.currentTraceContext = builder.currentTraceContext; this.sampler = builder.sampler; this.noop = new AtomicBoolean(); MutableSpan defaultSpan = new MutableSpan(builder.defaultSpan); // safe copy Set<SpanHandler> spanHandlers = new LinkedHashSet<>(builder.spanHandlers); // When present, the Zipkin handler is invoked after the user-supplied ones. if (builder.zipkinSpanReporter != null) { spanHandlers.add( ZipkinSpanHandler.newBuilder((Reporter<zipkin2.Span>) builder.zipkinSpanReporter) .errorTag(errorParser) .alwaysReportSpans(builder.alwaysReportSpans) .build()); } if (spanHandlers.isEmpty()) spanHandlers.add(new LogSpanHandler()); if (builder.trackOrphans) { spanHandlers.add(OrphanTracker.newBuilder().defaultSpan(defaultSpan).clock(clock).build()); } // Make sure any exceptions caused by span handlers don't crash callers SpanHandler spanHandler = NoopAwareSpanHandler.create(spanHandlers.toArray(new SpanHandler[0]), noop); boolean alwaysSampleLocal = builder.alwaysSampleLocal; for (SpanHandler handler : spanHandlers) { if (handler instanceof FinishedSpanHandler) { // Handle deprecated FinishedSpanHandler.alwaysSampleLocal if (((FinishedSpanHandler)handler).alwaysSampleLocal()) alwaysSampleLocal = true; } } this.tracer = new Tracer( builder.clock, builder.propagationFactory, spanHandler, new PendingSpans(defaultSpan, clock, spanHandler, noop), builder.sampler, builder.currentTraceContext, builder.traceId128Bit || propagationFactory.requires128BitTraceId(), builder.supportsJoin && propagationFactory.supportsJoin(), alwaysSampleLocal, noop ); // assign current IFF there's no instance already current CURRENT.compareAndSet(null, this); }
Example #4
Source File: Tracing.java From brave with Apache License 2.0 | 2 votes |
/** * @since 5.4 * @deprecated Since 5.12 {@linkplain #addSpanHandler(SpanHandler) add a span handler} that * implements {@link SpanHandler#end(TraceContext, MutableSpan, SpanHandler.Cause)} with {@link * SpanHandler.Cause#FINISHED} */ public Builder addFinishedSpanHandler(FinishedSpanHandler handler) { // Some configuration can coerce to no-op, ignore in this case. if (handler == FinishedSpanHandler.NOOP) return this; return addSpanHandler(handler); }