diff --git a/opentracing-web-servlet-filter/pom.xml b/opentracing-web-servlet-filter/pom.xml
index 6d92f9e..1bbba15 100644
--- a/opentracing-web-servlet-filter/pom.xml
+++ b/opentracing-web-servlet-filter/pom.xml
@@ -3,7 +3,7 @@
io.opentracing.contrib
opentracing-web-servlet-filter-parent
- 0.0.10-SNAPSHOT
+ 0.1.0-RC1-SNAPSHOT
4.0.0
diff --git a/opentracing-web-servlet-filter/src/main/java/io/opentracing/contrib/web/servlet/filter/ServletFilterSpanDecorator.java b/opentracing-web-servlet-filter/src/main/java/io/opentracing/contrib/web/servlet/filter/ServletFilterSpanDecorator.java
index dd0b031..25ce679 100644
--- a/opentracing-web-servlet-filter/src/main/java/io/opentracing/contrib/web/servlet/filter/ServletFilterSpanDecorator.java
+++ b/opentracing-web-servlet-filter/src/main/java/io/opentracing/contrib/web/servlet/filter/ServletFilterSpanDecorator.java
@@ -12,7 +12,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import io.opentracing.BaseSpan;
+import io.opentracing.Span;
import io.opentracing.tag.Tags;
/**
@@ -31,7 +31,7 @@ public interface ServletFilterSpanDecorator {
* @param httpServletRequest request
* @param span span to decorate
*/
- void onRequest(HttpServletRequest httpServletRequest, BaseSpan> span);
+ void onRequest(HttpServletRequest httpServletRequest, Span span);
/**
* Decorate span after {@link javax.servlet.Filter#doFilter(ServletRequest, ServletResponse, FilterChain)}. When it
@@ -41,7 +41,7 @@ public interface ServletFilterSpanDecorator {
* @param httpServletResponse response
* @param span span to decorate
*/
- void onResponse(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, BaseSpan> span);
+ void onResponse(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Span span);
/**
* Decorate span when an exception is thrown during processing in
@@ -53,7 +53,7 @@ public interface ServletFilterSpanDecorator {
* @param span span to decorate
*/
void onError(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
- Throwable exception, BaseSpan> span);
+ Throwable exception, Span span);
/**
* Decorate span on asynchronous request timeout. It is called in
@@ -65,7 +65,7 @@ void onError(HttpServletRequest httpServletRequest, HttpServletResponse httpServ
* @param span span to decorate
*/
void onTimeout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
- long timeout, BaseSpan> span);
+ long timeout, Span span);
/**
* Adds standard tags to span. {@link Tags#HTTP_URL}, {@link Tags#HTTP_STATUS}, {@link Tags#HTTP_METHOD} and
@@ -75,7 +75,7 @@ void onTimeout(HttpServletRequest httpServletRequest, HttpServletResponse httpSe
*/
ServletFilterSpanDecorator STANDARD_TAGS = new ServletFilterSpanDecorator() {
@Override
- public void onRequest(HttpServletRequest httpServletRequest, BaseSpan> span) {
+ public void onRequest(HttpServletRequest httpServletRequest, Span span) {
Tags.COMPONENT.set(span, "java-web-servlet");
Tags.HTTP_METHOD.set(span, httpServletRequest.getMethod());
@@ -85,13 +85,13 @@ public void onRequest(HttpServletRequest httpServletRequest, BaseSpan> span) {
@Override
public void onResponse(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
- BaseSpan> span) {
+ Span span) {
Tags.HTTP_STATUS.set(span, httpServletResponse.getStatus());
}
@Override
public void onError(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
- Throwable exception, BaseSpan> span) {
+ Throwable exception, Span span) {
Tags.ERROR.set(span, Boolean.TRUE);
span.log(logsForException(exception));
@@ -103,7 +103,7 @@ public void onError(HttpServletRequest httpServletRequest, HttpServletResponse h
@Override
public void onTimeout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
- long timeout, BaseSpan> span) {
+ long timeout, Span span) {
Tags.ERROR.set(span, Boolean.TRUE);
Map timeoutLogs = new HashMap<>();
diff --git a/opentracing-web-servlet-filter/src/main/java/io/opentracing/contrib/web/servlet/filter/TracingFilter.java b/opentracing-web-servlet-filter/src/main/java/io/opentracing/contrib/web/servlet/filter/TracingFilter.java
index 771f42c..eb96085 100644
--- a/opentracing-web-servlet-filter/src/main/java/io/opentracing/contrib/web/servlet/filter/TracingFilter.java
+++ b/opentracing-web-servlet-filter/src/main/java/io/opentracing/contrib/web/servlet/filter/TracingFilter.java
@@ -20,7 +20,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import io.opentracing.ActiveSpan;
+import io.opentracing.Scope;
import io.opentracing.Span;
import io.opentracing.SpanContext;
import io.opentracing.Tracer;
@@ -151,63 +151,62 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
SpanContext extractedContext = tracer.extract(Format.Builtin.HTTP_HEADERS,
new HttpServletRequestExtractAdapter(httpRequest));
- final ActiveSpan span = tracer.buildSpan(httpRequest.getMethod())
+ final Scope scope = tracer.buildSpan(httpRequest.getMethod())
.asChildOf(extractedContext)
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER)
- .startActive();
+ .startActive(false);
- httpRequest.setAttribute(SERVER_SPAN_CONTEXT, span.context());
+ httpRequest.setAttribute(SERVER_SPAN_CONTEXT, scope.span().context());
for (ServletFilterSpanDecorator spanDecorator: spanDecorators) {
- spanDecorator.onRequest(httpRequest, span);
+ spanDecorator.onRequest(httpRequest, scope.span());
}
try {
chain.doFilter(servletRequest, servletResponse);
if (!httpRequest.isAsyncStarted()) {
for (ServletFilterSpanDecorator spanDecorator : spanDecorators) {
- spanDecorator.onResponse(httpRequest, httpResponse, span);
+ spanDecorator.onResponse(httpRequest, httpResponse, scope.span());
}
}
// catch all exceptions (e.g. RuntimeException, ServletException...)
} catch (Throwable ex) {
for (ServletFilterSpanDecorator spanDecorator : spanDecorators) {
- spanDecorator.onError(httpRequest, httpResponse, ex, span);
+ spanDecorator.onError(httpRequest, httpResponse, ex, scope.span());
}
throw ex;
} finally {
if (httpRequest.isAsyncStarted()) {
- final ActiveSpan.Continuation cont = span.capture();
// what if async is already finished? This would not be called
httpRequest.getAsyncContext()
.addListener(new AsyncListener() {
@Override
public void onComplete(AsyncEvent event) throws IOException {
- try (ActiveSpan activeSpan = cont.activate()) {
+ try (Scope asyncScope = tracer.scopeManager().activate(scope.span())) {
for (ServletFilterSpanDecorator spanDecorator: spanDecorators) {
spanDecorator.onResponse((HttpServletRequest) event.getSuppliedRequest(),
- (HttpServletResponse) event.getSuppliedResponse(), span);
+ (HttpServletResponse) event.getSuppliedResponse(), asyncScope.span());
}
}
}
@Override
public void onTimeout(AsyncEvent event) throws IOException {
- try (ActiveSpan activeSpan = cont.activate()) {
+ try (Scope asyncScope = tracer.scopeManager().activate(scope.span())) {
for (ServletFilterSpanDecorator spanDecorator: spanDecorators) {
spanDecorator.onTimeout((HttpServletRequest) event.getSuppliedRequest(),
(HttpServletResponse) event.getSuppliedResponse(),
- event.getAsyncContext().getTimeout(), span);
+ event.getAsyncContext().getTimeout(), asyncScope.span());
}
}
}
@Override
public void onError(AsyncEvent event) throws IOException {
- try (ActiveSpan activeSpan = cont.activate()) {
+ try (Scope asyncScope = tracer.scopeManager().activate(scope.span())) {
for (ServletFilterSpanDecorator spanDecorator: spanDecorators) {
spanDecorator.onError((HttpServletRequest) event.getSuppliedRequest(),
- (HttpServletResponse) event.getSuppliedResponse(), event.getThrowable(), span);
+ (HttpServletResponse) event.getSuppliedResponse(), event.getThrowable(), asyncScope.span());
}
}
}
@@ -216,8 +215,13 @@ public void onError(AsyncEvent event) throws IOException {
public void onStartAsync(AsyncEvent event) throws IOException {
}
});
+ } else {
+ // If not async, then need to explicitly finish the span associated with the scope.
+ // This is necessary, as we don't know whether this request is being handled
+ // asynchronously until after the scope has already been started.
+ scope.span().finish();
}
- span.deactivate();
+ scope.close();
}
}
}
diff --git a/opentracing-web-servlet-filter/src/test/java/io/opentracing/contrib/web/servlet/filter/AbstractJettyTest.java b/opentracing-web-servlet-filter/src/test/java/io/opentracing/contrib/web/servlet/filter/AbstractJettyTest.java
index b4c479a..6b8c728 100644
--- a/opentracing-web-servlet-filter/src/test/java/io/opentracing/contrib/web/servlet/filter/AbstractJettyTest.java
+++ b/opentracing-web-servlet-filter/src/test/java/io/opentracing/contrib/web/servlet/filter/AbstractJettyTest.java
@@ -26,12 +26,13 @@
import org.junit.Before;
import org.mockito.Mockito;
-import io.opentracing.ActiveSpan;
+import io.opentracing.Scope;
+import io.opentracing.Span;
import io.opentracing.SpanContext;
import io.opentracing.Tracer;
import io.opentracing.mock.MockTracer;
import io.opentracing.util.GlobalTracer;
-import io.opentracing.util.ThreadLocalActiveSpanSource;
+import io.opentracing.util.ThreadLocalScopeManager;
/**
* @author Pavol Loffay
@@ -47,7 +48,7 @@ public abstract class AbstractJettyTest {
@Before
public void beforeTest() throws Exception {
- mockTracer = Mockito.spy(new MockTracer(new ThreadLocalActiveSpanSource(), MockTracer.Propagator.TEXT_MAP));
+ mockTracer = Mockito.spy(new MockTracer(new ThreadLocalScopeManager(), MockTracer.Propagator.TEXT_MAP));
ServletContextHandler servletContext = new ServletContextHandler();
servletContext.setContextPath(contextPath);
@@ -129,7 +130,7 @@ public CurrentSpanServlet(Tracer tracer) {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- tracer.activeSpan().setTag("CurrentSpan", true);
+ tracer.scopeManager().active().span().setTag("CurrentSpan", true);
}
}
@@ -161,13 +162,13 @@ public void doGet(HttpServletRequest request, HttpServletResponse response)
final AsyncContext asyncContext = request.startAsync(request, response);
// TODO: This could be avoided by using an OpenTracing aware Runnable (when available)
- final ActiveSpan.Continuation cont = tracer.activeSpan().capture();
+ final Span cont = tracer.scopeManager().active().span();
asyncContext.start(new Runnable() {
@Override
public void run() {
HttpServletResponse asyncResponse = (HttpServletResponse) asyncContext.getResponse();
- try (ActiveSpan activeSpan = cont.activate()) {
+ try (Scope activeScope = tracer.scopeManager().activate(cont, false)) {
try {
Thread.sleep(ASYNC_SLEEP_TIME_MS);
asyncResponse.setStatus(204);
diff --git a/pom.xml b/pom.xml
index c720592..76f2ede 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
io.opentracing.contrib
opentracing-web-servlet-filter-parent
- 0.0.10-SNAPSHOT
+ 0.1.0-RC1-SNAPSHOT
pom
${project.groupId}:${project.artifactId}
@@ -39,7 +39,7 @@
1.7
UTF-8
- 0.30.0
+ 0.31.0-RC1
3.0.1
4.12
1.10.19
diff --git a/travis/publish.sh b/travis/publish.sh
index 43c60b4..1070126 100755
--- a/travis/publish.sh
+++ b/travis/publish.sh
@@ -1,3 +1,17 @@
+#
+# Copyright 2016-2017 The OpenTracing Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+# in compliance with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software distributed under the License
+# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+# or implied. See the License for the specific language governing permissions and limitations under
+# the License.
+#
+
set -euo pipefail
set -x
@@ -46,20 +60,20 @@ check_travis_branch_equals_travis_tag() {
check_release_tag() {
tag="${TRAVIS_TAG}"
- if [[ "$tag" =~ ^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$ ]]; then
+ if [[ "$tag" =~ ^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(\.RC[[:digit:]]+)?$ ]]; then
echo "Build started by version tag $tag. During the release process tags like this"
echo "are created by the 'release' Maven plugin. Nothing to do here."
exit 0
- elif [[ ! "$tag" =~ ^release-[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$ ]]; then
- echo "You must specify a tag of the format 'release-0.0.0' to release this project."
+ elif [[ ! "$tag" =~ ^release-[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(\.RC[[:digit:]]+)?$ ]]; then
+ echo "You must specify a tag of the format 'release-0.0.0' or 'release-0.0.0.RC0' to release this project."
echo "The provided tag ${tag} doesn't match that. Aborting."
exit 1
fi
}
is_release_commit() {
- project_version=$(./mvnw help:evaluate -N -Dexpression=project.version|grep -v '\[')
- if [[ "$project_version" =~ ^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$ ]]; then
+ project_version=$(./mvnw help:evaluate -N -Dexpression=project.version|sed -n '/^[0-9]/p')
+ if [[ "$project_version" =~ ^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(\.RC[[:digit:]]+)?$ ]]; then
echo "Build started by release commit $project_version. Will synchronize to maven central."
return 0
else