Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix client scope not being closed #82

Merged
merged 3 commits into from
Mar 19, 2018

Conversation

pavolloffay
Copy link
Collaborator

Fixes #78

There are two solutions:

  • do not activate span - what is implemented in this PR
  • activate span. This has an advantage that other client filters can easily add data to span. - However this does not work because CXF response filter in async client is executed in a different thread so the scope cannot be closed.

cc @mabn

@pavolloffay pavolloffay requested a review from objectiser March 19, 2018 12:01
@pavolloffay pavolloffay changed the title Fix not deactivated client span Fix client scope not being closed Mar 19, 2018
@mabn
Copy link

mabn commented Mar 19, 2018

👍
Not activating is better because it solves the problem with ProcessingExceptions which cannot be intercepted (#30) and would also leave the scope without closing it.

@pavolloffay
Copy link
Collaborator Author

You are right, I thought that exception is thrown before the request filter, but it's not. So this is a much better option.

Copy link
Contributor

@objectiser objectiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - only a couple of minor things and a question.

@@ -2,6 +2,7 @@

import static io.opentracing.contrib.jaxrs2.internal.SpanWrapper.PROPERTY_NAME;

import io.opentracing.Scope;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like this is needed.

@@ -61,7 +62,7 @@ public void filter(ClientRequestContext requestContext) throws IOException {
.asChildOf(parentSpanContext);
}

Span span = spanBuilder.startActive(false).span();
Span span = spanBuilder.start();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the previous comments on the PR - what happens if an exception is thrown? If the scope wouldn't be closed, this also means the span is not finished?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, there is an issue for it and TODO in the test

@@ -56,14 +65,15 @@ protected void initTracing(ServletContextHandler context) {
public void testDefaultConfiguration() {
MockTracer mockTracer = new MockTracer(new ThreadLocalScopeManager(), Propagator.TEXT_MAP);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR, but could simplify this to just use default constructor.

@pavolloffay pavolloffay merged commit 050120a into opentracing-contrib:master Mar 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClientTracingFilter does not close activated Scope
3 participants