From cf16c53e7525b5e3243c7181faaed3f96e5be05c Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Mon, 7 Mar 2016 15:51:24 +0100 Subject: [PATCH] Sync docs from master to gh-pages --- spring-cloud-sleuth.html | 199 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 198 insertions(+), 1 deletion(-) diff --git a/spring-cloud-sleuth.html b/spring-cloud-sleuth.html index 69991bc29..03ea1e4fb 100644 --- a/spring-cloud-sleuth.html +++ b/spring-cloud-sleuth.html @@ -1250,10 +1250,207 @@ the number of dropped spans will get increased.

+
+

Integrations

+
+
+

Runnable and Callable

+
+

If you’re wrapping your logic in Runnable or Callable it’s enough to wrap those classes in their Sleuth representative.

+
+
+

Example for 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);
+
+
+
+

Example for 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);
+
+
+
+

That way you will ensure that a new Span is created and closed for each execution.

+
+
+
+

Hystrix

+
+

Custom Concurrency Strategy

+
+

We’re registering a custom HystrixConcurrencyStrategy +that wraps all Callable instances into their Sleuth representative - +the TraceCallable. The strategy either starts or continues a span depending on the fact whether tracing was already going +on before the Hystrix command was called.

+
+
+

To disable the custom Hystrix Concurrency Strategy set the spring.sleuth.hystrix.strategy.enabled to false.

+
+
+
+

Manual Command setting

+
+

Assuming that you have the following HystrixCommand:

+
+
+
+
HystrixCommand<String> hystrixCommand = new HystrixCommand<String>(setter) {
+	@Override
+	protected String run() throws Exception {
+		return someLogic();
+	}
+};
+
+
+
+

In order to pass the tracing information you have to wrap the same logic in the Sleuth version of the HystrixCommand which is the +TraceCommand:

+
+
+
+
TraceCommand<String> traceCommand = new TraceCommand<String>(tracer, traceKeys, setter) {
+	@Override
+	public String doRun() throws Exception {
+		return someLogic();
+	}
+};
+
+
+
+
+
+

HTTP integration

+
+

Features from this section can be disabled by providing the spring.sleuth.web.enabled property with value equal to false.

+
+
+

HTTP Filter

+
+

Via the TraceFilter all sampled incoming requests result in creation of a Span. That Span’s name is http: + the path to which + the request was sent. E.g. if the request was sent to /foo/bar then the name will be http:/foo/bar. You can configure which URIs you would + like to skip via the spring.sleuth.instrument.web.skipPattern property.

+
+
+
+

Async Servlet support

+
+

If your controller returns a Callable or a WebAsyncTask Spring Cloud Sleuth will continue the existing span instead of creating a new one.

+
+
+
+
+

HTTP client integration

+
+

Synchronous Rest Template

+
+

We’re injecting a RestTemplate interceptor that ensures that all the tracing information is passed to the requests. Each time a +call is made a new Span is created. It gets closed upon receiving the response. In order to block the synchronous RestTemplate features +just set spring.sleuth.client.enabled to false.

+
+
+
+

Asynchronous Rest Template

+
+

Custom instrumentation is set to create and close Spans upon sending and receiving requests. To block the AsyncRestTemplate +features set spring.sleuth.async.client.enabled to false.

+
+
+
+
+

Feign

+
+

By default Spring Cloud Sleuth provides integration with feign via the TraceFeignClientAutoConfiguration. You can disable it entirely +by setting spring.sleuth.feign.enabled to false.

+
+
+

Part of Feign instrumentation is done via a FeignBeanPostProcessor. You can disable it by providing the spring.sleuth.feign.processor.enabled equal to false.

+
+
+
+

Asynchronous communication

+
+

In Spring Cloud Sleuth we’re instrumenting async related components so that the tracing information is passed between threads. You can disable this behaviour +by setting the value of spring.sleuth.async.enabled to false.

+
+
+

@Async / @Scheduled annotated methods

+
+

If you annotate your method with @Async / @Scheduled then we’ll automatically create a new Span with the following characteristics:

+
+
+
    +
  • +

    the Span name will be the annotated method name

    +
  • +
  • +

    the Span will be tagged with that method’s class name and the method name too

    +
  • +
+
+
+
+

Executor, ExecutorService and ScheduledExecutorService

+
+

We’re providing LazyTraceExecutor, TraceableExecutorService and TraceableScheduledExecutorService. Those implementations +are creating Spans each time a new task is submitted, invoked or scheduled.

+
+
+
+
+

Messaging

+
+

All Spring Integration creates spans for publish and subscribe events. +To disable Spring Integration instrumentation, set spring.sleuth.integration.enabled to false.

+
+
+
+

Zuul

+
+

We registering Zuul filters to propagate the tracing information (the request header is enriched with tracing data). +To disable Zuul support set the spring.sleuth.zuul.enabled property to false.

+
+
+
+