Skip to content

Commit

Permalink
Using Jersey context rather then Helidon context. (helidon-io#3403)
Browse files Browse the repository at this point in the history
* Using Jersey context rather then Helidon context.
* Removed old code, kept comment.

Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
  • Loading branch information
tomas-langer committed Sep 23, 2021
1 parent 3b7abbe commit a33557c
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public void filter(ContainerRequestContext requestContext) {
context.register(spanScope);
context.register(ClientTracingFilter.class, span.context());
requestContext.setProperty(SPAN_PROPERTY, span);
requestContext.setProperty(SPAN_SCOPE_PROPERTY, spanScope);

if (context.get(TracingContext.class).isEmpty()) {
context.register(TracingContext.create(tracer, requestContext.getHeaders()));
Expand Down Expand Up @@ -166,8 +167,12 @@ public void filter(ContainerRequestContext requestContext, ContainerResponseCont
requestContext.setProperty(SPAN_FINISHED_PROPERTY, true);
span.finish();

Context context = Contexts.context().orElseThrow(() -> new IllegalStateException("Context must be available in Jersey"));
context.get(Scope.class).ifPresent(Scope::close);
// using the helidon context is not supported here, as we may be executing in a completion stage returned
// from a third party component
Scope scope = (Scope) requestContext.getProperty(SPAN_SCOPE_PROPERTY);
if (scope != null) {
scope.close();
}
}

/**
Expand Down

0 comments on commit a33557c

Please sign in to comment.