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


Java DefaultSpanNamer类代码示例

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


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

示例1: init

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Before
public void init() {
	initMocks(this);
	this.tracer = new DefaultTracer(new DelegateSampler(), new Random(),
			new DefaultSpanNamer(), this.spanLogger, this.spanReporter) {
		@Override
		public Span continueSpan(Span span) {
			TraceFilterTests.this.span = super.continueSpan(span);
			return TraceFilterTests.this.span;
		}
	};
	this.request = builder().buildRequest(new MockServletContext());
	this.response = new MockHttpServletResponse();
	this.response.setContentType(MediaType.APPLICATION_JSON_VALUE);
	this.filterChain = new MockFilterChain();
	this.httpTraceKeysInjector = new HttpTraceKeysInjector(this.tracer, this.traceKeys);
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:18,代码来源:TraceFilterTests.java

示例2: should_pass_tracing_information_when_using_Hystrix_commands

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Test
public void should_pass_tracing_information_when_using_Hystrix_commands() {
	Tracer tracer = new DefaultTracer(new AlwaysSampler(), new Random(),
			new DefaultSpanNamer(), new NoOpSpanLogger(), new NoOpSpanReporter());
	TraceKeys traceKeys = new TraceKeys();
	HystrixCommand.Setter setter = HystrixCommand.Setter
			.withGroupKey(HystrixCommandGroupKey.Factory.asKey("group"))
			.andCommandKey(HystrixCommandKey.Factory.asKey("command"));
	// tag::hystrix_command[]
	HystrixCommand<String> hystrixCommand = new HystrixCommand<String>(setter) {
		@Override
		protected String run() throws Exception {
			return someLogic();
		}
	};
	// end::hystrix_command[]
	// tag::trace_hystrix_command[]
	TraceCommand<String> traceCommand = new TraceCommand<String>(tracer, traceKeys, setter) {
		@Override
		public String doRun() throws Exception {
			return someLogic();
		}
	};
	// end::trace_hystrix_command[]

	String resultFromHystrixCommand = hystrixCommand.execute();
	String resultFromTraceCommand = traceCommand.execute();

	then(resultFromHystrixCommand).isEqualTo(resultFromTraceCommand);
	then(tracer.getCurrentSpan()).isNull();
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:32,代码来源:TraceCommandTests.java

示例3: should_set_runnable_name_to_annotated_value

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Test
public void should_set_runnable_name_to_annotated_value()
		throws ExecutionException, InterruptedException {
	ExecutorService executorService = Executors.newSingleThreadExecutor();
	SpanNamer spanNamer = new DefaultSpanNamer();
	Tracer tracer = Mockito.mock(Tracer.class);

	// tag::span_name_annotated_runnable_execution[]
	Runnable runnable = new TraceRunnable(tracer, spanNamer, new TaxCountingRunnable());
	Future<?> future = executorService.submit(runnable);
	// ... some additional logic ...
	future.get();
	// end::span_name_annotated_runnable_execution[]

	BDDMockito.then(tracer).should().createSpan(BDDMockito.eq("calculateTax"), BDDMockito.any(Span.class));
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:17,代码来源:SpringCloudSleuthDocTests.java

示例4: should_set_runnable_name_to_to_string_value

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Test
public void should_set_runnable_name_to_to_string_value()
		throws ExecutionException, InterruptedException {
	ExecutorService executorService = Executors.newSingleThreadExecutor();
	SpanNamer spanNamer = new DefaultSpanNamer();
	Tracer tracer = Mockito.mock(Tracer.class);

	// tag::span_name_to_string_runnable_execution[]
	Runnable runnable = new TraceRunnable(tracer, spanNamer, new Runnable() {
		@Override public void run() {
			// perform logic
		}

		@Override public String toString() {
			return "calculateTax";
		}
	});
	Future<?> future = executorService.submit(runnable);
	// ... some additional logic ...
	future.get();
	// end::span_name_to_string_runnable_execution[]

	BDDMockito.then(tracer).should().createSpan(BDDMockito.eq("calculateTax"), BDDMockito.any(Span.class));
	executorService.shutdown();
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:26,代码来源:SpringCloudSleuthDocTests.java

示例5: init

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Before
public void init() {
	initMocks(this);
	this.tracer = new DefaultTracer(new DelegateSampler(), new Random(),
			new DefaultSpanNamer(), this.spanLogger, this.spanReporter, new TraceKeys()) {
		@Override
		public Span continueSpan(Span span) {
			TraceFilterTests.this.span = super.continueSpan(span);
			return TraceFilterTests.this.span;
		}
	};
	this.request = builder().buildRequest(new MockServletContext());
	this.response = new MockHttpServletResponse();
	this.response.setContentType(MediaType.APPLICATION_JSON_VALUE);
	this.filterChain = new MockFilterChain();
	this.httpTraceKeysInjector = new HttpTraceKeysInjector(this.tracer, this.traceKeys);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:18,代码来源:TraceFilterTests.java

示例6: should_pass_tracing_information_when_using_Hystrix_commands

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Test
public void should_pass_tracing_information_when_using_Hystrix_commands() {
	Tracer tracer = new DefaultTracer(new AlwaysSampler(), new Random(),
			new DefaultSpanNamer(), new NoOpSpanLogger(), new NoOpSpanReporter(), new TraceKeys());
	TraceKeys traceKeys = new TraceKeys();
	HystrixCommand.Setter setter = withGroupKey(asKey("group"))
			.andCommandKey(HystrixCommandKey.Factory.asKey("command"));
	// tag::hystrix_command[]
	HystrixCommand<String> hystrixCommand = new HystrixCommand<String>(setter) {
		@Override
		protected String run() throws Exception {
			return someLogic();
		}
	};
	// end::hystrix_command[]
	// tag::trace_hystrix_command[]
	TraceCommand<String> traceCommand = new TraceCommand<String>(tracer, traceKeys, setter) {
		@Override
		public String doRun() throws Exception {
			return someLogic();
		}
	};
	// end::trace_hystrix_command[]

	String resultFromHystrixCommand = hystrixCommand.execute();
	String resultFromTraceCommand = traceCommand.execute();

	then(resultFromHystrixCommand).isEqualTo(resultFromTraceCommand);
	then(tracer.getCurrentSpan()).isNull();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:31,代码来源:TraceCommandTests.java

示例7: spanNamer

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
private SpanNamer spanNamer() {
	if (this.spanNamer == null) {
		try {
			this.spanNamer = this.beanFactory.getBean(SpanNamer.class);
		}
		catch (NoSuchBeanDefinitionException e) {
			log.warn("SpanNamer bean not found - will provide a manually created instance");
			return new DefaultSpanNamer();
		}
	}
	return this.spanNamer;
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:13,代码来源:LazyTraceExecutor.java

示例8: setup

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Before
public void setup() {
	this.tracer = new DefaultTracer(new AlwaysSampler(), new Random(),
			new DefaultSpanNamer(), new NoOpSpanLogger(), this.spanAccumulator);
	this.template.setInterceptors(Arrays.<ClientHttpRequestInterceptor>asList(
			new TraceRestTemplateInterceptor(this.tracer, new HttpRequestInjector(),
					new HttpTraceKeysInjector(this.tracer, new TraceKeys()))));
	TestSpanContextHolder.removeCurrentSpan();
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:10,代码来源:TraceRestTemplateInterceptorTests.java

示例9: setup

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Before
public void setup() {
	this.tracer = new DefaultTracer(new AlwaysSampler(), new Random(),
			new DefaultSpanNamer(), new NoOpSpanLogger(), new NoOpSpanReporter());
	this.template.setInterceptors(Arrays.<ClientHttpRequestInterceptor>asList(
			new TraceRestTemplateInterceptor(this.tracer, new HttpRequestInjector(),
					new HttpTraceKeysInjector(this.tracer, new TraceKeys()))));
	TestSpanContextHolder.removeCurrentSpan();
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:10,代码来源:TraceRestTemplateInterceptorIntegrationTests.java

示例10: should_delegate_to_callable_wrapped_in_a_local_component

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Test
public void should_delegate_to_callable_wrapped_in_a_local_component() throws Exception {
	LocalComponentTraceCallable<String> callable = new LocalComponentTraceCallable<>(this.tracer, new TraceKeys(), new DefaultSpanNamer(),
			() -> "hello");

	String response = callable.call();

	then(response).isEqualTo("hello");
	then(this.closedSpan).isALocalComponentSpan();
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:11,代码来源:LocalComponentTraceCallableTest.java

示例11: should_wrap_runnable_in_its_sleuth_representative

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Test
public void should_wrap_runnable_in_its_sleuth_representative() {
	SpanNamer spanNamer = new DefaultSpanNamer();
	Tracer tracer = new DefaultTracer(new AlwaysSampler(), new Random(), spanNamer,
			new NoOpSpanLogger(), new NoOpSpanReporter());
	Span initialSpan = tracer.createSpan("initialSpan");
	// tag::trace_runnable[]
	Runnable runnable = new Runnable() {
		@Override
		public void run() {
			// do some work
		}

		@Override
		public String toString() {
			return "spanNameFromToStringMethod";
		}
	};
	// Manual `TraceRunnable` creation with explicit "calculateTax" Span name
	Runnable traceRunnable = new TraceRunnable(tracer, spanNamer, runnable, "calculateTax");
	// Wrapping `Runnable` with `Tracer`. The Span name will be taken either from the
	// `@SpanName` annotation or from `toString` method
	Runnable traceRunnableFromTracer = tracer.wrap(runnable);
	// end::trace_runnable[]

	then(traceRunnable).isExactlyInstanceOf(TraceRunnable.class);
	then(traceRunnableFromTracer).isExactlyInstanceOf(TraceRunnable.class);
	tracer.close(initialSpan);
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:30,代码来源:SpringCloudSleuthDocTests.java

示例12: should_wrap_callable_in_its_sleuth_representative

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Test
public void should_wrap_callable_in_its_sleuth_representative() {
	SpanNamer spanNamer = new DefaultSpanNamer();
	Tracer tracer = new DefaultTracer(new AlwaysSampler(), new Random(), spanNamer,
			new NoOpSpanLogger(), new NoOpSpanReporter());
	Span initialSpan = tracer.createSpan("initialSpan");
	// tag::trace_callable[]
	Callable<String> callable = new Callable<String>() {
		@Override
		public String call() throws Exception {
			return someLogic();
		}

		@Override
		public String toString() {
			return "spanNameFromToStringMethod";
		}
	};
	// Manual `TraceCallable` creation with explicit "calculateTax" Span name
	Callable<String> traceCallable = new TraceCallable<>(tracer, spanNamer, callable, "calculateTax");
	// Wrapping `Callable` with `Tracer`. The Span name will be taken either from the
	// `@SpanName` annotation or from `toString` method
	Callable<String> traceCallableFromTracer = tracer.wrap(callable);
	// end::trace_callable[]

	then(traceCallable).isExactlyInstanceOf(TraceCallable.class);
	then(traceCallableFromTracer).isExactlyInstanceOf(TraceCallable.class);
	tracer.close(initialSpan);
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:30,代码来源:SpringCloudSleuthDocTests.java

示例13: tracingWorks

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Test
public void tracingWorks() {

	DefaultTracer tracer = new DefaultTracer(NeverSampler.INSTANCE, new Random(),
			new DefaultSpanNamer(), this.spanLogger, this.spanReporter);

	Span span = tracer.createSpan(CREATE_SIMPLE_TRACE, new AlwaysSampler());
	try {
		importantWork1(tracer);
	}
	finally {
		tracer.close(span);
	}

	verify(this.spanLogger, times(NUM_SPANS))
			.logStartedSpan(Mockito.any(Span.class), Mockito.any(Span.class));
	verify(this.spanReporter, times(NUM_SPANS))
			.report(Mockito.any(Span.class));

	ArgumentCaptor<Span> captor = ArgumentCaptor
			.forClass(Span.class);
	verify(this.spanReporter, atLeast(NUM_SPANS)).report(captor.capture());

	List<Span> spans = new ArrayList<>(captor.getAllValues());

	assertThat("spans was wrong size", spans.size(), is(NUM_SPANS));

	Span root = assertSpan(spans, null, CREATE_SIMPLE_TRACE);
	Span child = assertSpan(spans, root.getSpanId(), IMPORTANT_WORK_1);
	Span grandChild = assertSpan(spans, child.getSpanId(), IMPORTANT_WORK_2);

	List<Span> gen4 = findSpans(spans, grandChild.getSpanId());
	assertThat("gen4 was non-empty", gen4.isEmpty(), is(true));
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:35,代码来源:DefaultTracerTests.java

示例14: setup

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Before
public void setup() {
	this.tracer = new DefaultTracer(new AlwaysSampler(), new Random(),
			new DefaultSpanNamer(), new NoOpSpanLogger(), this.spanAccumulator, new TraceKeys());
	this.template.setInterceptors(Arrays.<ClientHttpRequestInterceptor>asList(
			new TraceRestTemplateInterceptor(this.tracer, new ZipkinHttpSpanInjector(),
					new HttpTraceKeysInjector(this.tracer, new TraceKeys()),
					new ExceptionMessageErrorParser())));
	TestSpanContextHolder.removeCurrentSpan();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:11,代码来源:TraceRestTemplateInterceptorTests.java

示例15: should_delegate_to_callable_wrapped_in_a_local_component

import org.springframework.cloud.sleuth.DefaultSpanNamer; //导入依赖的package包/类
@Test
public void should_delegate_to_callable_wrapped_in_a_local_component() throws Exception {
	SpanContinuingTraceCallable<String> callable = new SpanContinuingTraceCallable<>(this.tracer, new TraceKeys(), new DefaultSpanNamer(),
			() -> "hello");

	String response = callable.call();

	then(response).isEqualTo("hello");
	then(this.closedSpan).isALocalComponentSpan();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:11,代码来源:LocalComponentTraceCallableTest.java


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