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

Custom TracesSamplerCallback cannot access Spring request attributes when using OTEL #4192

Open
lcian opened this issue Feb 21, 2025 · 2 comments
Assignees
Labels
Platform: Java Type: Bug Something isn't working

Comments

@lcian
Copy link
Member

lcian commented Feb 21, 2025

Integration

sentry-opentelemetry-agentless-spring

Java Version

17

Version

8.1.0

Steps to Reproduce

  1. Create a project with spring-boot-starter-web (customer is using v2.7.11, but this is not relevant), sentry-spring-boot-starter and sentry-opentelemetry-agentless-spring
  2. Follow the docs to set up a custom TracesSamplerCallback that returns different sample rates based on the request path
  3. Start application and send HTTP request

Reported by pretchu in this Discord thread

Expected Result

Custom sample rate is returned based on request path, as correctly happens when using the SDK in non-OTEL mode.

Actual Result

context.getCustomSamplingContext() is always null, hence the request path cannot be inspected to make a sampling decision.

@adinauer
Copy link
Member

As a workaround in theory this SO post should work for OTel as well.

For the future we probably want to send OpenTelemetry span attributes into the sampling context.
We should check whether sampling is going to be implemented differently with the new Performance API.

@adinauer
Copy link
Member

adinauer commented Mar 3, 2025

AFAIR python recently address this, we should check how they implemented sending of OTel span attributes into the sampler callback.

@adinauer adinauer self-assigned this Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Java Type: Bug Something isn't working
Projects
Status: Needs Discussion
Development

No branches or pull requests

2 participants