diff --git a/README.md b/README.md
index 824962fc..d3f22d62 100644
--- a/README.md
+++ b/README.md
@@ -35,9 +35,9 @@ Access to the active span is straightforward:
```java
io.opentracing.Tracer tracer = ...;
...
-Scope scope = tracer.scopeManager().active();
-if (scope != null) {
- scope.span().log("...");
+Span span = tracer.scopeManager().activeSpan();
+if (span != null) {
+ span.log("...");
}
```
diff --git a/opentracing-api/src/main/java/io/opentracing/ScopeManager.java b/opentracing-api/src/main/java/io/opentracing/ScopeManager.java
index 64676bc0..90e7ff7e 100644
--- a/opentracing-api/src/main/java/io/opentracing/ScopeManager.java
+++ b/opentracing-api/src/main/java/io/opentracing/ScopeManager.java
@@ -17,8 +17,8 @@
/**
* The {@link ScopeManager} interface abstracts both the activation of {@link Span} instances via
- * {@link ScopeManager#activate(Span, boolean)} and access to an active {@link Span}/{@link Scope}
- * via {@link ScopeManager#active()}.
+ * {@link ScopeManager#activate(Span)} and access to an active {@link Span}
+ * via {@link ScopeManager#activeSpan()}.
*
* @see Scope
* @see Tracer#scopeManager()
@@ -37,10 +37,7 @@ public interface ScopeManager {
* is called.
*
*
- * This {@link Scope} instance can be accessed at any time through {@link #active()},
- * in case it is not possible for the user to store it (when used through middleware
- * or start/finish event hooks, for example). The corresponding {@link Span} can be
- * accessed through {@link #activeSpan()} likewise.
+ * The corresponding {@link Span} can be accessed at any time through {@link #activeSpan()}.
*
*
* Usage:
@@ -65,6 +62,7 @@ public interface ScopeManager {
Scope activate(Span span);
/**
+ * @deprecated use {@link #activeSpan()} instead.
* Return the currently active {@link Scope} which can be used to deactivate the currently active
* {@link Span}.
*
@@ -78,6 +76,7 @@ public interface ScopeManager {
*
* @return the {@link Scope active scope}, or null if none could be found.
*/
+ @Deprecated
Scope active();
/**
diff --git a/opentracing-api/src/main/java/io/opentracing/Tracer.java b/opentracing-api/src/main/java/io/opentracing/Tracer.java
index 966dc02c..eedca044 100644
--- a/opentracing-api/src/main/java/io/opentracing/Tracer.java
+++ b/opentracing-api/src/main/java/io/opentracing/Tracer.java
@@ -143,12 +143,12 @@ interface SpanBuilder {
*
* If
*
- *
the {@link Tracer}'s {@link ScopeManager#active()} is not null, and
+ *
the {@link Tracer}'s {@link ScopeManager#activeSpan()} is not null, and
*
no explicit references are added via {@link SpanBuilder#addReference}, and
*
{@link SpanBuilder#ignoreActiveSpan()} is not invoked,
*
* ... then an inferred {@link References#CHILD_OF} reference is created to the
- * {@link ScopeManager#active()} {@link SpanContext} when either {@link SpanBuilder#startActive(boolean)} or
+ * {@link ScopeManager#activeSpan()} {@link SpanContext} when either {@link SpanBuilder#startActive(boolean)} or
* {@link SpanBuilder#start} is invoked.
*
* @param referenceType the reference type, typically one of the constants defined in References
@@ -161,7 +161,7 @@ interface SpanBuilder {
SpanBuilder addReference(String referenceType, SpanContext referencedContext);
/**
- * Do not create an implicit {@link References#CHILD_OF} reference to the {@link ScopeManager#active()}).
+ * Do not create an implicit {@link References#CHILD_OF} reference to the {@link ScopeManager#activeSpan()}).
*/
SpanBuilder ignoreActiveSpan();
diff --git a/opentracing-mock/src/main/java/io/opentracing/mock/MockTracer.java b/opentracing-mock/src/main/java/io/opentracing/mock/MockTracer.java
index d8d17c8d..4ce9cfe5 100644
--- a/opentracing-mock/src/main/java/io/opentracing/mock/MockTracer.java
+++ b/opentracing-mock/src/main/java/io/opentracing/mock/MockTracer.java
@@ -272,8 +272,7 @@ public SpanContext extract(Format format, C carrier) {
@Override
public Span activeSpan() {
- Scope scope = this.scopeManager.active();
- return scope == null ? null : scope.span();
+ return this.scopeManager.activeSpan();
}
@Override
diff --git a/opentracing-testbed/README.md b/opentracing-testbed/README.md
index 9ebfdbc7..62f36c18 100644
--- a/opentracing-testbed/README.md
+++ b/opentracing-testbed/README.md
@@ -12,7 +12,7 @@ It shows continuation as a solution to finish span when last action is completed
- [active_span_replacement](src/test/java/io/opentracing/testbed/active_span_replacement) - start an isolated task and query for its result in another task/thread
- [actor_propagation](src/test/java/io/opentracing/testbed/actor_propagation) - tracing for blocking and non-blocking actor based tracing
- [client_server](src/test/java/io/opentracing/testbed/client_server) - typical client-server example
-- [common_request_handler](src/test/java/io/opentracing/testbed/common_request_handler) - one request handler for all requests
+- [concurrent_common_request_handler](src/test/java/io/opentracing/testbed/concurrent_common_request_handler) - one request handler for concurrent requests
- [error_reporting](src/test/java/io/opentracing/testbed/error_reporting) - a few common cases of error reporting
- [late_span_finish](src/test/java/io/opentracing/testbed/late_span_finish) - late parent span finish
- [listener_per_request](src/test/java/io/opentracing/testbed/listener_per_request) - one listener per request
@@ -20,3 +20,4 @@ It shows continuation as a solution to finish span when last action is completed
- [nested_callbacks](src/test/java/io/opentracing/testbed/nested_callbacks) - one callback at the time, defined in a pipeline fashion
- [promise_propagation](src/test/java/io/opentracing/testbed/promise_propagation) - tracing patterns for promises with callbacks
- [suspend_resume_propagation](src/test/java/io/opentracing/testbed/suspend_resume_propagation) - tracing pattern for interleaving of spans
+- [stateless_common_request_handler](src/test/java/io/opentracing/testbed/stateless_common_request_handler) - one stateless request handler for requests
diff --git a/opentracing-testbed/src/test/java/io/opentracing/testbed/active_span_replacement/ActiveSpanReplacementTest.java b/opentracing-testbed/src/test/java/io/opentracing/testbed/active_span_replacement/ActiveSpanReplacementTest.java
index 74e0ef63..2976da75 100644
--- a/opentracing-testbed/src/test/java/io/opentracing/testbed/active_span_replacement/ActiveSpanReplacementTest.java
+++ b/opentracing-testbed/src/test/java/io/opentracing/testbed/active_span_replacement/ActiveSpanReplacementTest.java
@@ -66,7 +66,7 @@ public void test() throws Exception {
assertNotEquals(spans.get(0).context().traceId(), spans.get(1).context().traceId());
assertEquals(0, spans.get(0).parentId());
- assertNull(tracer.scopeManager().active());
+ assertNull(tracer.scopeManager().activeSpan());
}
private void submitAnotherTask(final Span initialSpan) {
diff --git a/opentracing-testbed/src/test/java/io/opentracing/testbed/actor_propagation/ActorPropagationTest.java b/opentracing-testbed/src/test/java/io/opentracing/testbed/actor_propagation/ActorPropagationTest.java
index 4aee337d..c40c31b7 100644
--- a/opentracing-testbed/src/test/java/io/opentracing/testbed/actor_propagation/ActorPropagationTest.java
+++ b/opentracing-testbed/src/test/java/io/opentracing/testbed/actor_propagation/ActorPropagationTest.java
@@ -84,7 +84,7 @@ public void testActorTell() {
.isEqualTo(finished.get(1).context().traceId());
assertThat(getByTag(finished, Tags.SPAN_KIND, Tags.SPAN_KIND_CONSUMER)).hasSize(2);
assertThat(getOneByTag(finished, Tags.SPAN_KIND, Tags.SPAN_KIND_PRODUCER)).isNotNull();
- assertThat(tracer.scopeManager().active()).isNull();
+ assertThat(tracer.scopeManager().activeSpan()).isNull();
}
}
@@ -126,7 +126,7 @@ public void testActorAsk() throws ExecutionException, InterruptedException {
.isEqualTo(finished.get(1).context().traceId());
assertThat(getByTag(finished, Tags.SPAN_KIND, Tags.SPAN_KIND_CONSUMER)).hasSize(2);
assertThat(getOneByTag(finished, Tags.SPAN_KIND, Tags.SPAN_KIND_PRODUCER)).isNotNull();
- assertThat(tracer.scopeManager().active()).isNull();
+ assertThat(tracer.scopeManager().activeSpan()).isNull();
}
}
}
diff --git a/opentracing-testbed/src/test/java/io/opentracing/testbed/client_server/TestClientServerTest.java b/opentracing-testbed/src/test/java/io/opentracing/testbed/client_server/TestClientServerTest.java
index 266f9751..56aaccec 100644
--- a/opentracing-testbed/src/test/java/io/opentracing/testbed/client_server/TestClientServerTest.java
+++ b/opentracing-testbed/src/test/java/io/opentracing/testbed/client_server/TestClientServerTest.java
@@ -65,6 +65,6 @@ public void test() throws Exception {
assertEquals(finished.get(0).context().traceId(), finished.get(1).context().traceId());
assertNotNull(getOneByTag(finished, Tags.SPAN_KIND, Tags.SPAN_KIND_CLIENT));
assertNotNull(getOneByTag(finished, Tags.SPAN_KIND, Tags.SPAN_KIND_SERVER));
- assertNull(tracer.scopeManager().active());
+ assertNull(tracer.scopeManager().activeSpan());
}
}
diff --git a/opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/Client.java b/opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/Client.java
similarity index 97%
rename from opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/Client.java
rename to opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/Client.java
index 60004dff..076b7ea9 100644
--- a/opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/Client.java
+++ b/opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/Client.java
@@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package io.opentracing.testbed.common_request_handler;
+package io.opentracing.testbed.concurrent_common_request_handler;
import io.opentracing.testbed.TestUtils;
import org.slf4j.Logger;
diff --git a/opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/Context.java b/opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/Context.java
similarity index 91%
rename from opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/Context.java
rename to opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/Context.java
index 75ad49db..52fc1b93 100644
--- a/opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/Context.java
+++ b/opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/Context.java
@@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package io.opentracing.testbed.common_request_handler;
+package io.opentracing.testbed.concurrent_common_request_handler;
import java.util.HashMap;
diff --git a/opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/HandlerTest.java b/opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/HandlerTest.java
similarity index 97%
rename from opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/HandlerTest.java
rename to opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/HandlerTest.java
index ae8f939a..eadf9b83 100644
--- a/opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/HandlerTest.java
+++ b/opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/HandlerTest.java
@@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package io.opentracing.testbed.common_request_handler;
+package io.opentracing.testbed.concurrent_common_request_handler;
import io.opentracing.Scope;
import io.opentracing.Span;
@@ -68,7 +68,7 @@ public void two_requests() throws Exception {
assertEquals(0, finished.get(0).parentId());
assertEquals(0, finished.get(1).parentId());
- assertNull(tracer.scopeManager().active());
+ assertNull(tracer.scopeManager().activeSpan());
}
/**
diff --git a/opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/README.md b/opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/README.md
similarity index 83%
rename from opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/README.md
rename to opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/README.md
index 001daa2c..2c50489f 100644
--- a/opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/README.md
+++ b/opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/README.md
@@ -1,6 +1,6 @@
-# Common Request Handler example.
+# Concurrent common Request Handler example.
-This example shows a `Span` used with `RequestHandler`, which is used as a middleware (as in web frameworks) to manage a new `Span` per operation through its `beforeRequest()`/`afterResponse()` methods.
+This example shows a `Span` used with `RequestHandler`, which is used as a middleware (as in web frameworks) to concurrently manage a new `Span` per operation through its `beforeRequest()`/`afterResponse()` methods.
Since its methods are not guaranteed to be run in the same thread, activation of such `Span`s is not done.
diff --git a/opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/RequestHandler.java b/opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/RequestHandler.java
similarity index 97%
rename from opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/RequestHandler.java
rename to opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/RequestHandler.java
index cdde25ff..b53205cb 100644
--- a/opentracing-testbed/src/test/java/io/opentracing/testbed/common_request_handler/RequestHandler.java
+++ b/opentracing-testbed/src/test/java/io/opentracing/testbed/concurrent_common_request_handler/RequestHandler.java
@@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package io.opentracing.testbed.common_request_handler;
+package io.opentracing.testbed.concurrent_common_request_handler;
import io.opentracing.Span;
import io.opentracing.SpanContext;
diff --git a/opentracing-testbed/src/test/java/io/opentracing/testbed/error_reporting/ErrorReportingTest.java b/opentracing-testbed/src/test/java/io/opentracing/testbed/error_reporting/ErrorReportingTest.java
index 2bb6b622..2679697c 100644
--- a/opentracing-testbed/src/test/java/io/opentracing/testbed/error_reporting/ErrorReportingTest.java
+++ b/opentracing-testbed/src/test/java/io/opentracing/testbed/error_reporting/ErrorReportingTest.java
@@ -52,7 +52,6 @@ public void testSimpleError() {
span.finish();
}
- assertNull(tracer.scopeManager().active());
assertNull(tracer.scopeManager().activeSpan());
List spans = tracer.finishedSpans();
@@ -112,7 +111,6 @@ public void testErrorRecovery() {
}
span.finish();
- assertNull(tracer.scopeManager().active());
assertNull(tracer.scopeManager().activeSpan());
List spans = tracer.finishedSpans();
diff --git a/opentracing-testbed/src/test/java/io/opentracing/testbed/late_span_finish/LateSpanFinishTest.java b/opentracing-testbed/src/test/java/io/opentracing/testbed/late_span_finish/LateSpanFinishTest.java
index 812466b6..12dd2828 100644
--- a/opentracing-testbed/src/test/java/io/opentracing/testbed/late_span_finish/LateSpanFinishTest.java
+++ b/opentracing-testbed/src/test/java/io/opentracing/testbed/late_span_finish/LateSpanFinishTest.java
@@ -58,7 +58,7 @@ public void test() throws Exception {
assertSameTrace(spans);
- assertNull(tracer.scopeManager().active());
+ assertNull(tracer.scopeManager().activeSpan());
}
diff --git a/opentracing-testbed/src/test/java/io/opentracing/testbed/listener_per_request/ListenerTest.java b/opentracing-testbed/src/test/java/io/opentracing/testbed/listener_per_request/ListenerTest.java
index 455f84ee..6cd14c0c 100644
--- a/opentracing-testbed/src/test/java/io/opentracing/testbed/listener_per_request/ListenerTest.java
+++ b/opentracing-testbed/src/test/java/io/opentracing/testbed/listener_per_request/ListenerTest.java
@@ -44,6 +44,6 @@ public void test() throws Exception {
List finished = tracer.finishedSpans();
assertEquals(1, finished.size());
assertNotNull(getOneByTag(finished, Tags.SPAN_KIND, Tags.SPAN_KIND_CLIENT));
- assertNull(tracer.scopeManager().active());
+ assertNull(tracer.scopeManager().activeSpan());
}
}
diff --git a/opentracing-testbed/src/test/java/io/opentracing/testbed/multiple_callbacks/Client.java b/opentracing-testbed/src/test/java/io/opentracing/testbed/multiple_callbacks/Client.java
index 0c50f4e0..a36718ec 100644
--- a/opentracing-testbed/src/test/java/io/opentracing/testbed/multiple_callbacks/Client.java
+++ b/opentracing-testbed/src/test/java/io/opentracing/testbed/multiple_callbacks/Client.java
@@ -18,6 +18,7 @@
import io.opentracing.Tracer;
import io.opentracing.util.AutoFinishScope;
import io.opentracing.util.AutoFinishScope.Continuation;
+import io.opentracing.util.AutoFinishScopeManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,8 +41,7 @@ public Client(Tracer tracer) {
}
public Future