@Before public void setUp() throws Exception { mockTracer = new MockTracer(new ThreadLocalScopeManager(), new B3Propagator()); }
@Before public void setUp() throws Exception { tracingPlugin = mock(TracingPlugin.class); mockTracer = new MockTracer(new ThreadLocalScopeManager(), new B3Propagator()); when(tracingPlugin.getTracer()).thenReturn(mockTracer); loggingSpanReporter = new LoggingSpanReporter(); final ConfigurationRegistry configuration = mock(ConfigurationRegistry.class); when(configuration.getConfig(TracingPlugin.class)).thenReturn(tracingPlugin); loggingSpanReporter.init(configuration); }
@Before public void setUp() { mockTracer = new MockTracer(new ThreadLocalScopeManager(), new B3Propagator()); tracingPlugin = mock(TracingPlugin.class); SpanWrappingTracer spanWrappingTracer = new SpanWrappingTracer(mockTracer, asList( new SpanContextInformation.SpanContextSpanEventListener(), new SpanContextInformation.SpanFinalizer())); when(tracingPlugin.getTracer()).thenReturn(spanWrappingTracer); when(tracingPlugin.isSampled(any())).thenReturn(true); reportingSpanEventListener = mock(ReportingSpanEventListener.class); when(tracingPlugin.getReportingSpanEventListener()).thenReturn(reportingSpanEventListener); servletPlugin = mock(ServletPlugin.class); when(servletPlugin.isClientSpanCollectionEnabled()).thenReturn(true); when(servletPlugin.isParseUserAgent()).thenReturn(false); servlet = new ClientSpanServlet(tracingPlugin, servletPlugin); }
@Before public void setUp() throws Exception { Stagemonitor.reset(); SharedMetricRegistries.clear(); this.corePlugin = mock(CorePlugin.class); when(corePlugin.isStagemonitorActive()).thenReturn(true); final MockTracer tracer = new MockTracer(new ThreadLocalScopeManager(), new B3Propagator()); TracingPlugin tracingPlugin = mock(TracingPlugin.class); when(tracingPlugin.getTracer()).thenReturn(tracer); mdcSpanInterceptor = new MDCSpanEventListener(corePlugin, tracingPlugin); spanWrapper = new SpanWrapper(tracer.buildSpan("operation name").start(),"operation name", 1, 1, Collections.emptyList(), new ConcurrentHashMap<>()); }
@Before public void setUp() throws Exception { this.configuration = mock(ConfigurationRegistry.class); this.tracingPlugin = mock(TracingPlugin.class); when(configuration.getConfig(CorePlugin.class)).thenReturn(corePlugin); when(configuration.getConfig(TracingPlugin.class)).thenReturn(tracingPlugin); when(configuration.getConfig(ElasticsearchTracingPlugin.class)).thenReturn(spy(new ElasticsearchTracingPlugin())); when(corePlugin.getElasticsearchClient()).thenReturn(elasticsearchClient); when(corePlugin.getMetricRegistry()).thenReturn(new Metric2Registry()); when(tracingPlugin.getDefaultRateLimitSpansPerMinute()).thenReturn(1000000d); when(tracingPlugin.getProfilerRateLimitPerMinuteOption()).thenReturn(mock(ConfigurationOption.class)); when(tracingPlugin.isPseudonymizeUserNames()).thenReturn(true); when(tracingPlugin.isSampled(any())).thenReturn(true); reporter = new ElasticsearchSpanReporter(); reporter.init(configuration); final ReportingSpanEventListener reportingSpanEventListener = new ReportingSpanEventListener(configuration); reportingSpanEventListener.addReporter(reporter); final SamplePriorityDeterminingSpanEventListener samplePriorityDeterminingSpanInterceptor = mock(SamplePriorityDeterminingSpanEventListener.class); when(samplePriorityDeterminingSpanInterceptor.onSetTag(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).then(invocation -> invocation.getArgument(1)); when(samplePriorityDeterminingSpanInterceptor.onSetTag(ArgumentMatchers.anyString(), ArgumentMatchers.anyBoolean())).then(invocation -> invocation.getArgument(1)); when(samplePriorityDeterminingSpanInterceptor.onSetTag(ArgumentMatchers.anyString(), ArgumentMatchers.any(Number.class))).then(invocation -> invocation.getArgument(1)); tracer = TracingPlugin.createSpanWrappingTracer(new MockTracer(new ThreadLocalScopeManager(), new B3Propagator()), configuration, new Metric2Registry(), Collections.emptyList(), samplePriorityDeterminingSpanInterceptor, reportingSpanEventListener); when(tracingPlugin.getTracer()).thenReturn(tracer); }
@Before public void setUp() throws Exception { configuration = mock(ConfigurationRegistry.class); TracingPlugin tracingPlugin = mock(TracingPlugin.class); when(tracingPlugin.getRequestMonitor()).thenReturn(mock(RequestMonitor.class)); when(tracingPlugin.getProfilerRateLimitPerMinuteOption()).thenReturn(mock(ConfigurationOption.class)); when(tracingPlugin.isSampled(any())).thenReturn(true); when(configuration.getConfig(TracingPlugin.class)).thenReturn(tracingPlugin); servletPlugin = mock(ServletPlugin.class); when(servletPlugin.isWidgetAndStagemonitorEndpointsAllowed(any(HttpServletRequest.class))).thenReturn(Boolean.TRUE); when(configuration.getConfig(ServletPlugin.class)).thenReturn(servletPlugin); final CorePlugin corePlugin = mock(CorePlugin.class); when(corePlugin.getThreadPoolQueueCapacityLimit()).thenReturn(1000); when(configuration.getConfig(CorePlugin.class)).thenReturn(corePlugin); WidgetAjaxSpanReporter reporter = new WidgetAjaxSpanReporter(); spanServlet = new SpanServlet(configuration, reporter, 1500); spanServlet.init(); connectionId = UUID.randomUUID().toString(); final SamplePriorityDeterminingSpanEventListener samplePriorityDeterminingSpanInterceptor = mock(SamplePriorityDeterminingSpanEventListener.class); when(samplePriorityDeterminingSpanInterceptor.onSetTag(anyString(), anyString())).then(invocation -> invocation.getArgument(1)); when(samplePriorityDeterminingSpanInterceptor.onSetTag(anyString(), anyBoolean())).then(invocation -> invocation.getArgument(1)); when(samplePriorityDeterminingSpanInterceptor.onSetTag(anyString(), any(Number.class))).then(invocation -> invocation.getArgument(1)); final ReportingSpanEventListener reportingSpanEventListener = new ReportingSpanEventListener(configuration); reportingSpanEventListener.addReporter(reporter); Tracer tracer = TracingPlugin.createSpanWrappingTracer(new MockTracer(new ThreadLocalScopeManager(), new B3Propagator()), configuration, new Metric2Registry(), ServiceLoader.load(SpanEventListenerFactory.class), samplePriorityDeterminingSpanInterceptor, reportingSpanEventListener); GlobalTracerTestHelper.override(tracer); when(tracingPlugin.getTracer()).thenReturn(tracer); }
final RequestMonitor requestMonitor = new RequestMonitor(configuration, mock(Metric2Registry.class)); doReturn(requestMonitor).when(tracingPlugin).getRequestMonitor(); final SpanWrappingTracer spanWrappingTracer = new SpanWrappingTracer(new MockTracer(new ThreadLocalScopeManager(), new B3Propagator()), Arrays.asList(new SpanContextInformation.SpanContextSpanEventListener(), new SpanContextInformation.SpanFinalizer())); doAnswer(invocation -> {
public APIExtensionsTracer(Tracer tracer) { if (tracer instanceof NoopTracer) { this.scopeManager = new ThreadLocalScopeManager(); this.wrappedTracer = null; } else { this.scopeManager = null; this.wrappedTracer = tracer; } }
private void defaultScopeManager() { if(scopeManager == null) { scopeManager = new ThreadLocalScopeManager(); } }
public MockTracer() { this(new ThreadLocalScopeManager(), Propagator.TEXT_MAP); }
@Override public Tracer getTracer(String serviceName) { boolean LogEnabled = Boolean.valueOf(configuration.getFirstProperty(TracingConstants.LOG_ENABLED)); if (LogEnabled) { Tracer tracer = NoopTracerFactory.create(); Reporter reporter = new TracingReporter(LogFactory.getLog(TracingConstants.TRACER)); Tracer tracerR = new TracerR(tracer, reporter, new ThreadLocalScopeManager()); GlobalTracer.register(tracerR); return tracerR; } return null; }
private WavefrontTracer(Reporter reporter, List<Pair<String, String>> tags, ApplicationTags applicationTags, List<Sampler> samplers, Supplier<Long> reportFrequencyMillis) { scopeManager = new ThreadLocalScopeManager(); registry = new PropagatorRegistry(); this.reporter = reporter; this.tags = tags; this.samplers = samplers; applicationServicePrefix = applicationTags.getApplication() + "." + applicationTags.getService() + "."; this.reportFrequencyMillis = reportFrequencyMillis; /** * Tracing spans will be converted to metrics and histograms and will be reported to Wavefront * only if you use the WavefrontSpanReporter */ WavefrontSpanReporter wfSpanReporter = getWavefrontSpanReporter(reporter); if (wfSpanReporter != null) { Pair<WavefrontInternalReporter, HeartbeaterService> pair = instantiateWavefrontStatsReporter(wfSpanReporter, applicationTags); wfInternalReporter = pair._1; heartbeaterService = pair._2; } else { wfInternalReporter = null; heartbeaterService = null; } }
@Override public Tracer getTracer(String serviceName) { String hostname = configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_HOST) != null ? configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_HOST) : TracingConstants.ZIPKIN_DEFAULT_HOST; int port = configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_PORT) != null ? Integer.parseInt(configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_PORT)) : TracingConstants.ZIPKIN_DEFAULT_PORT; boolean tracerLogEnabled = Boolean.parseBoolean(configuration.getFirstProperty(TracingConstants.CONFIG_TRACER_LOG_ENABLED) != null ? configuration.getFirstProperty(TracingConstants.CONFIG_TRACER_LOG_ENABLED) : TracingConstants.DEFAULT_TRACER_LOG_ENABLED); OkHttpSender sender = OkHttpSender.create("http://" + hostname + ":" + port + TracingConstants.ZIPKIN_API_CONTEXT); Tracer tracer = BraveTracer.create(Tracing.newBuilder() .localServiceName(serviceName) .spanReporter(AsyncReporter.builder(sender).build()) .propagationFactory(ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, TracingConstants.REQUEST_ID)) .build()); if (tracerLogEnabled) { Reporter reporter = new TracingReporter(LogFactory.getLog(TracingConstants.TRACER)); Tracer tracerR = new TracerR(tracer, reporter, new ThreadLocalScopeManager()); GlobalTracer.register(tracerR); return tracerR; } else { GlobalTracer.register(tracer); return tracer; } }
Tracer tracerR = new TracerR(tracer, reporter, new ThreadLocalScopeManager()); GlobalTracer.register(tracerR); return tracerR;