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 Context Breaks with manual instrumentation when async method Invokes by ratpack for a single request #12363

Open
NaveenRamu opened this issue Sep 30, 2024 · 5 comments
Labels
bug Something isn't working needs author feedback Waiting for additional feedback from the author needs triage New issue that requires triage stale

Comments

@NaveenRamu
Copy link

NaveenRamu commented Sep 30, 2024

Describe the bug

When using Ratpack2 with OpenTelemetry (Otel) manual instrumentation in a reactive environment, tracing continuity can break when synchronous methods are invoked. This loss of trace context leads to incomplete or broken traces, resulting in the generation of a new tracing ID for subsequent invocations.

Steps to reproduce

Download the attached sample code and execute it. After execution, import the provided Postman collection and send the request. Observe the logs. GitHub Link

Expected behavior

Only one trace ID should be generated across all spans for a single API request to ensure continuity in tracing.

Actual behavior

Different trace ids are generated for each method execution.

Javaagent or library instrumentation version

ratpack-1.7

Environment

JDK: 1.8
OS: Linux
Framework: Ratpack2 (version: 2.0.0-rc-1)

Additional context

No response

@NaveenRamu NaveenRamu added bug Something isn't working needs triage New issue that requires triage labels Sep 30, 2024
@laurit
Copy link
Contributor

laurit commented Sep 30, 2024

When using Ratpack2 with OpenTelemetry (Otel) manual instrumentation in a reactive environment, tracing continuity can break when synchronous methods are invoked. This loss of trace context leads to incomplete or broken traces, resulting in the generation of a new tracing ID for subsequent invocations.

When implementing manual instrumentation it is up to you to correctly propagate context.

Javaagent or library instrumentation version
ratpack-1.7

Our ratpack-1.7 instrumentation does not work with ratpack2. As far as I can tell you have only included the jar, this doesn't do anything. To make it work I'd make a copy of the ratpack-1.7 instrumentation and compile it against ratpack2, fix all compile errors because of the moved classes and then add the instrumentation to the server like it is done in the test https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/v1_7/server/RatpackHttpServerTest.groovy

Download the attached sample code and execute it. After execution, import the provided Postman collection and send the request. Observe the logs. GitHub Link

You could make life easier for everybody by adding the source of your test app directly to the github repo instead of adding a zip there.

@laurit laurit added the needs author feedback Waiting for additional feedback from the author label Sep 30, 2024
Copy link
Contributor

github-actions bot commented Oct 7, 2024

This has been automatically marked as stale because it has been marked as needing author feedback and has not had any activity for 7 days. It will be closed automatically if there is no response from the author within 7 additional days from this comment.

@github-actions github-actions bot added the stale label Oct 7, 2024
@NaveenRamu
Copy link
Author

For reference, is there any project or example that uses Ratpack 1.7 library with manual instrumentation?

@github-actions github-actions bot removed needs author feedback Waiting for additional feedback from the author stale labels Oct 14, 2024
@laurit
Copy link
Contributor

laurit commented Oct 14, 2024

For reference, is there any project or example that uses Ratpack 1.7 library with manual instrumentation?

There are tests in https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/v1_7 that illustrate how the instrumentation can be used.

@laurit laurit added the needs author feedback Waiting for additional feedback from the author label Oct 14, 2024
Copy link
Contributor

This has been automatically marked as stale because it has been marked as needing author feedback and has not had any activity for 7 days. It will be closed automatically if there is no response from the author within 7 additional days from this comment.

@github-actions github-actions bot added the stale label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs author feedback Waiting for additional feedback from the author needs triage New issue that requires triage stale
Projects
None yet
Development

No branches or pull requests

2 participants