当前位置: 首页>>代码示例>>Java>>正文


Java ThreadLocalScopeManager类代码示例

本文整理汇总了Java中io.opentracing.util.ThreadLocalScopeManager的典型用法代码示例。如果您正苦于以下问题:Java ThreadLocalScopeManager类的具体用法?Java ThreadLocalScopeManager怎么用?Java ThreadLocalScopeManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ThreadLocalScopeManager类属于io.opentracing.util包,在下文中一共展示了ThreadLocalScopeManager类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import io.opentracing.util.ThreadLocalScopeManager; //导入依赖的package包/类
@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);
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:26,代码来源:ElasticsearchSpanReporterIntegrationTest.java

示例2: setUp

import io.opentracing.util.ThreadLocalScopeManager; //导入依赖的package包/类
@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);
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:17,代码来源:ClientSpanServletTest.java

示例3: setUp

import io.opentracing.util.ThreadLocalScopeManager; //导入依赖的package包/类
@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<>());
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:17,代码来源:MDCSpanEventListenerTest.java

示例4: beforeTest

import io.opentracing.util.ThreadLocalScopeManager; //导入依赖的package包/类
@Before
public void beforeTest() throws Exception {
    mockTracer = Mockito.spy(new MockTracer(new ThreadLocalScopeManager(), MockTracer.Propagator.TEXT_MAP));

    ServletContextHandler servletContext = new ServletContextHandler();
    servletContext.setContextPath(contextPath);
    servletContext.addServlet(TestServlet.class, "/hello");
    
    ServletHolder asyncServletHolder = new ServletHolder(new AsyncServlet(mockTracer));
    servletContext.addServlet(asyncServletHolder, "/async");
    asyncServletHolder.setAsyncSupported(true);
    servletContext.addServlet(AsyncImmediateExitServlet.class, "/asyncImmediateExit")
            .setAsyncSupported(true);

    servletContext.addServlet(new ServletHolder(new LocalSpanServlet(mockTracer)), "/localSpan");
    servletContext.addServlet(new ServletHolder(new CurrentSpanServlet(mockTracer)), "/currentSpan");
    servletContext.addServlet(ExceptionServlet.class, "/servletException");

    servletContext.addFilter(new FilterHolder(tracingFilter()), "/*", EnumSet.of(DispatcherType.REQUEST,
            DispatcherType.FORWARD, DispatcherType.ASYNC, DispatcherType.ERROR, DispatcherType.INCLUDE));
    servletContext.addFilter(ErrorFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));

    jettyServer = new Server(0);
    jettyServer.setHandler(servletContext);
    jettyServer.start();
    serverPort = ((ServerConnector)jettyServer.getConnectors()[0]).getLocalPort();
}
 
开发者ID:opentracing-contrib,项目名称:java-web-servlet-filter,代码行数:28,代码来源:AbstractJettyTest.java

示例5: setUp

import io.opentracing.util.ThreadLocalScopeManager; //导入依赖的package包/类
@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);
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:35,代码来源:SpanServletTest.java

示例6: setUp

import io.opentracing.util.ThreadLocalScopeManager; //导入依赖的package包/类
@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);
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:11,代码来源:LoggingSpanReporterTest.java

示例7: tracer

import io.opentracing.util.ThreadLocalScopeManager; //导入依赖的package包/类
@Bean
public MockTracer tracer() {
  return new MockTracer(new ThreadLocalScopeManager(), Propagator.TEXT_MAP);
}
 
开发者ID:opentracing-contrib,项目名称:java-kafka-client,代码行数:5,代码来源:TestConfiguration.java

示例8: MockTracer

import io.opentracing.util.ThreadLocalScopeManager; //导入依赖的package包/类
public MockTracer() {
    this(new ThreadLocalScopeManager(), Propagator.TEXT_MAP);
}
 
开发者ID:opentracing,项目名称:opentracing-java,代码行数:4,代码来源:MockTracer.java

示例9: before

import io.opentracing.util.ThreadLocalScopeManager; //导入依赖的package包/类
@Before
public void before() throws Exception {
	/*
	when(requestMonitor.monitor(any(MonitoredRequest.class))).then(new Answer<SpanContextInformation>() {
		@Override
		public SpanContextInformation answer(InvocationOnMock invocation) throws Throwable {
			MonitoredRequest request = (MonitoredRequest) invocation.getArguments()[0];
			request.execute();
			doReturn("testName").when(spanContext).getOperationName();
			return spanContext;
		}
	});
	*/

	doReturn(servletPlugin).when(configuration).getConfig(ServletPlugin.class);
	doReturn(tracingPlugin).when(configuration).getConfig(TracingPlugin.class);
	doReturn(corePlugin).when(configuration).getConfig(CorePlugin.class);
	doReturn(true).when(servletPlugin).isWidgetEnabled();
	doReturn(true).when(servletPlugin).isWidgetAndStagemonitorEndpointsAllowed(any(HttpServletRequest.class));
	doReturn(true).when(servletPlugin).isClientSpanCollectionEnabled();
	doReturn(true).when(servletPlugin).isClientSpanCollectionInjectionEnabled();
	doReturn(true).when(corePlugin).isStagemonitorActive();
	doReturn(mock(GrafanaClient.class)).when(corePlugin).getGrafanaClient();
	doReturn(1000000d).when(tracingPlugin).getProfilerRateLimitPerMinute();
	when(tracingPlugin.isSampled(any())).thenReturn(true);
	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 -> {
		spanWrappingTracer.addEventListenerFactory(invocation.getArgument(0));
		return null;
	}).when(tracingPlugin).addSpanEventListenerFactory(any());
	doReturn(spanWrappingTracer).when(tracingPlugin).getTracer();
	doReturn("testApplication").when(corePlugin).getApplicationName();
	doReturn("testInstance").when(corePlugin).getInstanceName();
	servletPlugin.initializePlugin(new StagemonitorPlugin.InitArguments(mock(Metric2Registry.class), configuration,
			mock(MeasurementSession.class), mock(HealthCheckRegistry.class)));

	initFilter();
	assertThat(tracingPlugin.getTracer().scopeManager().active()).isNull();
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:43,代码来源:HttpRequestMonitorFilterTest.java

示例10: setUp

import io.opentracing.util.ThreadLocalScopeManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	mockTracer = new MockTracer(new ThreadLocalScopeManager(), new B3Propagator());
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:5,代码来源:SpanJsonModuleTest.java


注:本文中的io.opentracing.util.ThreadLocalScopeManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。