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

Tracing not propagated when using SE and Jersey client #838

Closed
tomas-langer opened this issue Jul 16, 2019 · 3 comments · Fixed by #905
Closed

Tracing not propagated when using SE and Jersey client #838

tomas-langer opened this issue Jul 16, 2019 · 3 comments · Fixed by #905
Assignees
Labels
jax-rs JAX-RS and Jersey related issues P3 SE tracing

Comments

@tomas-langer
Copy link
Member

Helidon 1.1.2

When I use jersey reactive client, tracing is not automatically propagated and I need to send SpanContext as request property:

Invocation.Builder requestBuilder = webTarget.request();

        // propagate security if defined
        request.context()
                .get(SecurityContext.class)
                .ifPresent(ctx -> requestBuilder.property(ClientSecurityFeature.PROPERTY_CONTEXT, ctx));

        // propagate tracing
        requestBuilder.property(ClientTracingFilter.CURRENT_SPAN_CONTEXT_PROPERTY_NAME, request.spanContext());

        // and reactive jersey client call
        requestBuilder.rx()
                .get(String.class)
                .thenAccept(response::send)
                .exceptionally(throwable -> {
                    // process exception
                    response.status(Http.Status.INTERNAL_SERVER_ERROR_500);
                    response.send("Failed with: " + throwable);
                    return null;
                });
@tomas-langer
Copy link
Member Author

tomas-langer commented Aug 14, 2019

Related to eclipse-ee4j/jersey#4227

@tomas-langer
Copy link
Member Author

This problem is caused by the usage of rx(). This uses an executor service that cannot be easily overridden.
The PR for Jersey was an attempt to fix a behavior when explicit executor sevice (configured in client builder) is ignored and an executor service provider (registered using method register) is used instead.
We must create a Helidon client feature that would autoregister an executor service provider, so we can wrap the executor service with Contexts.wrap, as otherwise we cannot propagate context.

@tomas-langer tomas-langer added the jax-rs JAX-RS and Jersey related issues label Aug 15, 2019
@tomas-langer
Copy link
Member Author

Fix is based on automatic feature that configures an ExecutorServiceProvider with the Jersey client.
Behavior may be overridden via JaxRsClient.defaultExecutor to use an explicit executor service, or via JaxRsClient.configureDefaults(Config) to use a configuration based approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jax-rs JAX-RS and Jersey related issues P3 SE tracing
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant