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 Span.current() behavior with OTel - return Optional.empty() if there is no current span #8574

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

tjquinno
Copy link
Member

Description

Resolves #8573

For some time, our OTel implementation of Span.current() used OTel's Span.current() which (also for some time) always returns a value. If there is no current span, OTel returns a new no-op span (with the trace and span IDs set to 0). (Because Jaeger has come to rely on OTel as well, this affected the Jaeger current span behavior as well.)

But our Span.current() contract says we return Optional.empty() if there is no current span.

This PR instead uses OTel's Span.fromContextOrNull to retrieve the actual current span if there is one or 'null' if there is none. Then our code wraps that in an Optional, thus honoring the documented contract.

Documentation

Bug fix; no doc impact

…current span

Signed-off-by: Tim Quinn <tim.quinn@oracle.com>
@tjquinno tjquinno self-assigned this Mar 27, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Mar 27, 2024
@tjquinno tjquinno merged commit fae450c into helidon-io:helidon-3.x Mar 27, 2024
12 checks passed
@tjquinno tjquinno deleted the 3.x-current-span branch March 27, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants