@Override public void onFinish(SpanWrapper spanWrapper, String operationName, long durationNanos) { final SpanContextInformation contextInfo = SpanContextInformation.forSpan(spanWrapper); if (contextInfo.getCallTree() != null) { try { Profiler.stop(); if (tracingPlugin.isSampled(spanWrapper)) { determineIfExcludeCallTree(contextInfo); if (isAddCallTreeToSpan(contextInfo, operationName)) { addCallTreeToSpan(contextInfo, spanWrapper, operationName); } } } finally { Profiler.clearMethodCallParent(); } } }
private SpanWrappingTracer initTracer() { return new SpanWrappingTracer(new MockTracer(), Arrays.asList( new SpanContextInformation.SpanContextSpanEventListener(), new SamplePriorityDeterminingSpanEventListener(configurationRegistry, Collections.emptyList(), Collections.emptyList()), new CallTreeSpanEventListener(mock(Metric2Registry.class), tracingPlugin), new SpanContextInformation.SpanFinalizer()) ); }
@Override public void onStart(SpanWrapper spanWrapper) { final SpanContextInformation contextInfo = SpanContextInformation.forSpan(spanWrapper); if (tracingPlugin.isSampled(spanWrapper) && contextInfo.getPreExecutionInterceptorContext() != null) { determineIfEnableProfiler(spanWrapper, contextInfo); if (!Profiler.isProfilingActive() && contextInfo.getPreExecutionInterceptorContext().isCollectCallTree()) { contextInfo.setCallTree(Profiler.activateProfiling("total")); } } }
public static SpanWrappingTracer createSpanWrappingTracer(final Tracer delegate, ConfigurationRegistry configuration, final Metric2Registry metricRegistry, final Iterable<SpanEventListenerFactory> spanInterceptorFactories, final SamplePriorityDeterminingSpanEventListener samplePriorityDeterminingSpanInterceptor, final ReportingSpanEventListener reportingSpanEventListener) { final CorePlugin corePlugin = configuration.getConfig(CorePlugin.class); final TracingPlugin tracingPlugin = configuration.getConfig(TracingPlugin.class); final SpanWrappingTracer spanWrappingTracer = new SpanWrappingTracer(delegate); spanWrappingTracer.addEventListenerFactory(new SpanContextInformation.SpanContextSpanEventListener()); spanWrappingTracer.addEventListenerFactory(samplePriorityDeterminingSpanInterceptor); spanWrappingTracer.addEventListenerFactory(new MDCSpanEventListener(corePlugin, tracingPlugin)); spanWrappingTracer.addEventListenerFactory(new B3IdentifierTagger(tracingPlugin)); for (SpanEventListenerFactory spanEventListenerFactory : spanInterceptorFactories) { spanWrappingTracer.addEventListenerFactory(spanEventListenerFactory); } final ThreadPoolExecutor singleThreadDeamonPool = ExecutorUtils.createSingleThreadDeamonPool("metric-tracking", 1000, corePlugin); final MetricsSpanEventListener spanEventListener = new MetricsSpanEventListener(metricRegistry, singleThreadDeamonPool, tracingPlugin); spanWrappingTracer.addEventListenerFactory(spanEventListener); spanWrappingTracer.addEventListenerFactory(new CallTreeSpanEventListener(corePlugin.getMetricRegistry(), tracingPlugin)); spanWrappingTracer.addEventListenerFactory(new AnonymizingSpanEventListener(tracingPlugin)); spanWrappingTracer.addEventListenerFactory(reportingSpanEventListener); spanWrappingTracer.addEventListenerFactory(new SpanContextInformation.SpanFinalizer()); return spanWrappingTracer; }