Skip to content

Conversation

@adinauer
Copy link
Member

📜 Description

SamplingContext now has a getAttribute method granting access to OpenTelemetry span attributes when Sentry is used in OpenTelemetry mode.

💡 Motivation and Context

Fixes #4192

💚 How did you test it?

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

@github-actions
Copy link
Contributor

github-actions bot commented Mar 12, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 9c9c831

@github-actions
Copy link
Contributor

github-actions bot commented Mar 12, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 434.14 ms 465.71 ms 31.57 ms
Size 1.58 MiB 2.21 MiB 642.37 KiB

Previous results on branch: feat/access-to-otel-attributes-in-sampler

Startup times

Revision Plain With Sentry Diff
0427eb9 422.63 ms 469.83 ms 47.21 ms

App size

Revision Plain With Sentry Diff
0427eb9 1.58 MiB 2.21 MiB 642.37 KiB

Copy link
Member

@lcian lcian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor nits but LGTM.

We are calling it getAttribute which could possibly be an API we will have on Span as part of the attributes API that is in the works. As far as I understand this new concept of attributes will correspond to the OTEL one we are using here, so I agree on this naming.

Let's not forget to update the relevant docs: https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/sampling/#setting-a-sampling-function

Co-authored-by: Lorenzo Cian <lorenzo.cian@sentry.io>
@adinauer adinauer merged commit 9683566 into main Mar 13, 2025
35 checks passed
@adinauer adinauer deleted the feat/access-to-otel-attributes-in-sampler branch March 13, 2025 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom TracesSamplerCallback cannot access Spring request attributes when using OTEL

4 participants