spring.sleuth.opentracing
}
};
// Manual `TraceRunnable` creation with explicit "calculateTax" Span name
-Runnable traceRunnable = new TraceRunnable(tracer, spanNamer, errorParser,
- runnable, "calculateTax");
+Runnable traceRunnable = new TraceRunnable(tracing, spanNamer, 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);The following example shows how to do so for Callable:
Callable<String> callable = new Callable<String>() {
@@ -30,8 +30,8 @@ Runnable traceRunnableFromTracer = tracing.currentTraceContext().wrap(runnable);
}
};
// Manual `TraceCallable` creation with explicit "calculateTax" Span name
-Callable<String> traceCallable = new TraceCallable<>(tracer, spanNamer, errorParser,
- callable, "calculateTax");
+Callable<String> traceCallable = new TraceCallable<>(tracing, spanNamer, 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);
That way, you ensure that a new span is created and closed for each execution.
We register a custom HystrixConcurrencyStrategy called TraceCallable that wraps all Callable instances in their Sleuth representative.
diff --git a/multi/multi__naming_spans.html b/multi/multi__naming_spans.html
index 893861c8e..ca170d699 100644
--- a/multi/multi__naming_spans.html
+++ b/multi/multi__naming_spans.html
@@ -7,14 +7,14 @@ The name should be low cardinality, so it should not include identifiers.
@Override public void run() {
// perform logic
}
-}
In this case, when processed in the following manner, the span is named calculateTax:
Runnable runnable = new TraceRunnable(tracer, spanNamer, errorParser,
+}In this case, when processed in the following manner, the span is named calculateTax:
Runnable runnable = new TraceRunnable(tracing, spanNamer,
new TaxCountingRunnable());
Future<?> future = executorService.submit(runnable);
// ... some additional logic ...
future.get();
It is pretty rare to create separate classes for Runnable or Callable.
Typically, one creates an anonymous instance of those classes.
You cannot annotate such classes.
-To overcome that limitation, if there is no @SpanName annotation present, we check whether the class has a custom implementation of the toString() method.
Running such code leads to creating a span named calculateTax, as shown in the following example:
Runnable runnable = new TraceRunnable(tracer, spanNamer, errorParser, new Runnable() {
+To overcome that limitation, if there is no @SpanName annotation present, we check whether the class has a custom implementation of the toString() method.Running such code leads to creating a span named calculateTax, as shown in the following example:
Runnable runnable = new TraceRunnable(tracing, spanNamer, new Runnable() {
@Override public void run() {
// perform logic
}
diff --git a/single/spring-cloud-sleuth.html b/single/spring-cloud-sleuth.html
index 2f4406ec0..86a46637b 100644
--- a/single/spring-cloud-sleuth.html
+++ b/single/spring-cloud-sleuth.html
@@ -538,14 +538,14 @@ The name should be low cardinality, so it should not include identifiers.
@Override public void run() {
// perform logic
}
-}
In this case, when processed in the following manner, the span is named calculateTax:
Runnable runnable = new TraceRunnable(tracer, spanNamer, errorParser,
+}In this case, when processed in the following manner, the span is named calculateTax:
Runnable runnable = new TraceRunnable(tracing, spanNamer,
new TaxCountingRunnable());
Future<?> future = executorService.submit(runnable);
// ... some additional logic ...
future.get();
It is pretty rare to create separate classes for Runnable or Callable.
Typically, one creates an anonymous instance of those classes.
You cannot annotate such classes.
-To overcome that limitation, if there is no @SpanName annotation present, we check whether the class has a custom implementation of the toString() method.
Running such code leads to creating a span named calculateTax, as shown in the following example:
Runnable runnable = new TraceRunnable(tracer, spanNamer, errorParser, new Runnable() {
+To overcome that limitation, if there is no @SpanName annotation present, we check whether the class has a custom implementation of the toString() method.Running such code leads to creating a span named calculateTax, as shown in the following example:
Runnable runnable = new TraceRunnable(tracing, spanNamer, new Runnable() {
@Override public void run() {
// perform logic
}
@@ -705,8 +705,8 @@ If you wish to disable this, set spring.sleuth.opentracing
}
};
// Manual `TraceRunnable` creation with explicit "calculateTax" Span name
-Runnable traceRunnable = new TraceRunnable(tracer, spanNamer, errorParser,
- runnable, "calculateTax");
+Runnable traceRunnable = new TraceRunnable(tracing, spanNamer, 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);
The following example shows how to do so for Callable:
Callable<String> callable = new Callable<String>() {
@@ -721,8 +721,8 @@ Runnable traceRunnableFromTracer = tracing.currentTraceContext().wrap(runnable);
}
};
// Manual `TraceCallable` creation with explicit "calculateTax" Span name
-Callable<String> traceCallable = new TraceCallable<>(tracer, spanNamer, errorParser,
- callable, "calculateTax");
+Callable<String> traceCallable = new TraceCallable<>(tracing, spanNamer, 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);
That way, you ensure that a new span is created and closed for each execution.
We register a custom HystrixConcurrencyStrategy called TraceCallable that wraps all Callable instances in their Sleuth representative.
diff --git a/spring-cloud-sleuth.xml b/spring-cloud-sleuth.xml
index 40501555b..c67b58ad0 100644
--- a/spring-cloud-sleuth.xml
+++ b/spring-cloud-sleuth.xml
@@ -1226,7 +1226,7 @@ class TaxCountingRunnable implements Runnable {
}
}
In this case, when processed in the following manner, the span is named calculateTax :
-Runnable runnable = new TraceRunnable(tracer, spanNamer, errorParser,
+Runnable runnable = new TraceRunnable(tracing, spanNamer,
new TaxCountingRunnable());
Future<?> future = executorService.submit(runnable);
// ... some additional logic ...
@@ -1239,7 +1239,7 @@ Typically, one creates an anonymous instance of those classes.
You cannot annotate such classes.
To overcome that limitation, if there is no @SpanName annotation present, we check whether the class has a custom implementation of the toString() method.
Running such code leads to creating a span named calculateTax , as shown in the following example:
-Runnable runnable = new TraceRunnable(tracer, spanNamer, errorParser, new Runnable() {
+Runnable runnable = new TraceRunnable(tracing, spanNamer, new Runnable() {
@Override public void run() {
// perform logic
}
@@ -1558,8 +1558,8 @@ If you wish to disable this, set spring.sleuth.opentracing.enabled
@@ -1576,8 +1576,8 @@ Runnable traceRunnableFromTracer = tracing.currentTraceContext().wrap(runnable);
}
};
// Manual `TraceCallable` creation with explicit "calculateTax" Span name
-Callable<String> traceCallable = new TraceCallable<>(tracer, spanNamer, errorParser,
- callable, "calculateTax");
+Callable<String> traceCallable = new TraceCallable<>(tracing, spanNamer, 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);