use of org.springframework.cloud.sleuth.ExceptionMessageErrorParser in project spring-cloud-sleuth by spring-cloud.
the class SleuthHystrixConcurrencyStrategyTest method should_not_override_existing_custom_strategies.
@Test
public void should_not_override_existing_custom_strategies() {
HystrixPlugins.getInstance().registerCommandExecutionHook(new MyHystrixCommandExecutionHook());
HystrixPlugins.getInstance().registerEventNotifier(new MyHystrixEventNotifier());
HystrixPlugins.getInstance().registerMetricsPublisher(new MyHystrixMetricsPublisher());
HystrixPlugins.getInstance().registerPropertiesStrategy(new MyHystrixPropertiesStrategy());
new SleuthHystrixConcurrencyStrategy(this.tracing.tracer(), new DefaultSpanNamer(), new ExceptionMessageErrorParser());
then(HystrixPlugins.getInstance().getCommandExecutionHook()).isExactlyInstanceOf(MyHystrixCommandExecutionHook.class);
then(HystrixPlugins.getInstance().getEventNotifier()).isExactlyInstanceOf(MyHystrixEventNotifier.class);
then(HystrixPlugins.getInstance().getMetricsPublisher()).isExactlyInstanceOf(MyHystrixMetricsPublisher.class);
then(HystrixPlugins.getInstance().getPropertiesStrategy()).isExactlyInstanceOf(MyHystrixPropertiesStrategy.class);
}
use of org.springframework.cloud.sleuth.ExceptionMessageErrorParser in project spring-cloud-sleuth by spring-cloud.
the class SpringCloudSleuthDocTests method should_set_runnable_name_to_to_string_value.
@Test
public void should_set_runnable_name_to_to_string_value() throws ExecutionException, InterruptedException {
ExecutorService executorService = Executors.newSingleThreadExecutor();
SpanNamer spanNamer = new DefaultSpanNamer();
ErrorParser errorParser = new ExceptionMessageErrorParser();
// tag::span_name_to_string_runnable_execution[]
Runnable runnable = new TraceRunnable(tracer, spanNamer, errorParser, 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[]
List<zipkin2.Span> spans = this.reporter.getSpans();
then(spans).hasSize(1);
then(spans.get(0).name()).isEqualTo("calculatetax");
executorService.shutdown();
}
use of org.springframework.cloud.sleuth.ExceptionMessageErrorParser in project spring-cloud-sleuth by spring-cloud.
the class SpringCloudSleuthDocTests method should_wrap_callable_in_its_sleuth_representative.
@Test
public void should_wrap_callable_in_its_sleuth_representative() {
SpanNamer spanNamer = new DefaultSpanNamer();
ErrorParser errorParser = new ExceptionMessageErrorParser();
// 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, errorParser, callable, "calculateTax");
// Wrapping `Callable` with `Tracing`. That way the current span will be available
// in the thread of `Callable`
Callable<String> traceCallableFromTracer = tracing.currentTraceContext().wrap(callable);
// end::trace_callable[]
}
use of org.springframework.cloud.sleuth.ExceptionMessageErrorParser in project spring-cloud-sleuth by spring-cloud.
the class SpringCloudSleuthDocTests method should_set_runnable_name_to_annotated_value.
// end::span_name_annotation[]
@Test
public void should_set_runnable_name_to_annotated_value() throws ExecutionException, InterruptedException {
ExecutorService executorService = Executors.newSingleThreadExecutor();
SpanNamer spanNamer = new DefaultSpanNamer();
ErrorParser errorParser = new ExceptionMessageErrorParser();
// tag::span_name_annotated_runnable_execution[]
Runnable runnable = new TraceRunnable(tracer, spanNamer, errorParser, new TaxCountingRunnable());
Future<?> future = executorService.submit(runnable);
// ... some additional logic ...
future.get();
// end::span_name_annotated_runnable_execution[]
List<zipkin2.Span> spans = this.reporter.getSpans();
then(spans).hasSize(1);
then(spans.get(0).name()).isEqualTo("calculatetax");
}
Aggregations