use of org.springframework.cloud.sleuth.DefaultSpanNamer in project spring-cloud-sleuth by spring-cloud.
the class SleuthHystrixConcurrencyStrategyTest method should_delegate_work_to_custom_hystrix_concurrency_strategy.
@Test
public void should_delegate_work_to_custom_hystrix_concurrency_strategy() throws Exception {
HystrixConcurrencyStrategy strategy = Mockito.mock(HystrixConcurrencyStrategy.class);
HystrixPlugins.getInstance().registerConcurrencyStrategy(strategy);
SleuthHystrixConcurrencyStrategy sleuthStrategy = new SleuthHystrixConcurrencyStrategy(this.tracing.tracer(), new DefaultSpanNamer(), new ExceptionMessageErrorParser());
sleuthStrategy.wrapCallable(() -> "foo");
sleuthStrategy.getThreadPool(HystrixThreadPoolKey.Factory.asKey(""), Mockito.mock(HystrixThreadPoolProperties.class));
sleuthStrategy.getThreadPool(HystrixThreadPoolKey.Factory.asKey(""), Mockito.mock(HystrixProperty.class), Mockito.mock(HystrixProperty.class), Mockito.mock(HystrixProperty.class), TimeUnit.DAYS, Mockito.mock(BlockingQueue.class));
sleuthStrategy.getBlockingQueue(10);
sleuthStrategy.getRequestVariable(Mockito.mock(HystrixLifecycleForwardingRequestVariable.class));
BDDMockito.then(strategy).should().wrapCallable((Callable) BDDMockito.any());
BDDMockito.then(strategy).should().getThreadPool(BDDMockito.any(), BDDMockito.any());
BDDMockito.then(strategy).should().getThreadPool(BDDMockito.any(), BDDMockito.any(), BDDMockito.any(), BDDMockito.any(), BDDMockito.any(), BDDMockito.any());
BDDMockito.then(strategy).should().getThreadPool(BDDMockito.any(), BDDMockito.any(), BDDMockito.any(), BDDMockito.any(), BDDMockito.any(), BDDMockito.any());
BDDMockito.then(strategy).should().getBlockingQueue(10);
BDDMockito.then(strategy).should().getRequestVariable(BDDMockito.any());
}
use of org.springframework.cloud.sleuth.DefaultSpanNamer in project spring-cloud-sleuth by spring-cloud.
the class SleuthHystrixConcurrencyStrategyTest method should_wrap_delegates_callable_in_trace_callable_when_delegate_is_present.
@Test
public void should_wrap_delegates_callable_in_trace_callable_when_delegate_is_present() throws Exception {
HystrixPlugins.getInstance().registerConcurrencyStrategy(new MyHystrixConcurrencyStrategy());
SleuthHystrixConcurrencyStrategy strategy = new SleuthHystrixConcurrencyStrategy(this.tracing.tracer(), new DefaultSpanNamer(), new ExceptionMessageErrorParser());
Callable<String> callable = strategy.wrapCallable(() -> "hello");
then(callable).isInstanceOf(TraceCallable.class);
then(callable.call()).isEqualTo("executed_custom_callable");
}
use of org.springframework.cloud.sleuth.DefaultSpanNamer in project spring-cloud-sleuth by spring-cloud.
the class SpringCloudSleuthDocTests method should_wrap_runnable_in_its_sleuth_representative.
@Test
public void should_wrap_runnable_in_its_sleuth_representative() {
SpanNamer spanNamer = new DefaultSpanNamer();
ErrorParser errorParser = new ExceptionMessageErrorParser();
// 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, errorParser, runnable, "calculateTax");
// Wrapping `Runnable` with `Tracing`. That way the current span will be available
// in the thread of `Runnable`
Runnable traceRunnableFromTracer = tracing.currentTraceContext().wrap(runnable);
// end::trace_runnable[]
then(traceRunnable).isExactlyInstanceOf(TraceRunnable.class);
}
use of org.springframework.cloud.sleuth.DefaultSpanNamer in project spring-cloud-sleuth by spring-cloud.
the class TraceableExecutorServiceTests method beanFactory.
BeanFactory beanFactory() {
BDDMockito.given(this.beanFactory.getBean(Tracer.class)).willReturn(this.tracer);
BDDMockito.given(this.beanFactory.getBean(SpanNamer.class)).willReturn(new DefaultSpanNamer());
BDDMockito.given(this.beanFactory.getBean(ErrorParser.class)).willReturn(new ExceptionMessageErrorParser());
return this.beanFactory;
}
use of org.springframework.cloud.sleuth.DefaultSpanNamer in project spring-cloud-sleuth by spring-cloud.
the class TraceableExecutorServiceTests method callables.
private List callables() {
List list = new ArrayList<>();
list.add(new TraceCallable<>(this.tracing.tracer(), new DefaultSpanNamer(), new ExceptionMessageErrorParser(), () -> "foo"));
list.add((Callable) () -> "bar");
return list;
}
Aggregations