fix(otel): Copy active span on scope clone#4878
Merged
adinauer merged 3 commits intofeat/feature-flags-on-spansfrom Nov 11, 2025
Merged
fix(otel): Copy active span on scope clone#4878adinauer merged 3 commits intofeat/feature-flags-on-spansfrom
adinauer merged 3 commits intofeat/feature-flags-on-spansfrom
Conversation
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| ef06876 | 312.94 ms | 370.33 ms | 57.39 ms |
| cb9cf5e | 313.21 ms | 359.20 ms | 46.00 ms |
| 8f87720 | 367.76 ms | 460.02 ms | 92.26 ms |
| 8a5f7d1 | 322.31 ms | 431.93 ms | 109.63 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| ef06876 | 1.58 MiB | 2.12 MiB | 553.23 KiB |
| cb9cf5e | 1.58 MiB | 2.12 MiB | 549.76 KiB |
| 8f87720 | 1.58 MiB | 2.12 MiB | 549.76 KiB |
| 8a5f7d1 | 1.58 MiB | 2.12 MiB | 549.68 KiB |
alexander-alderman-webb
approved these changes
Nov 7, 2025
adinauer
added a commit
that referenced
this pull request
Nov 11, 2025
* Add scope based feature flags * fix equals * add serialization tests * Create new reference on buffer clone * add comment explaining the merge method * optimize merge method * make flag and result nullable params * handle empty/noop buffer on merge and add tests for it * optimize add method * format; fix test * Add rules for feature flags and mention in overview_dev * Fix duplicate check * Update sentry/src/main/java/io/sentry/SentryOptions.java Co-authored-by: Lorenzo Cian <17258265+lcian@users.noreply.github.com> * Format code * Add feature flags to spans * move feature flag buffer to span context; add e2e test * e2e tests; fix POTel feature flags * Format code * test feature flag serialization from SentryTracer * Format code * fix e2e test assertions; handle null data map * Format code * changelog * changelog * nullable getFeatureFlags * update changelog * address pr review feedback * Format code * fix(otel): Copy active span on scope clone (#4878) * Copy active span when cloning scope * changelog * api --------- Co-authored-by: Lorenzo Cian <17258265+lcian@users.noreply.github.com> Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
When cloning a
Scopewe now copy theactiveSpanover.💡 Motivation and Context
Not copying it means we don't know what the current span is, causing
Sentry.getSpan()to returnnullafter current scope has been forked.This showed up, when implementing feature flags on spans where the span created by OpenTelemetry auto instrumentation was not returned by
Sentry.getSpan()andaddFeatureFlagdid not write to that span.💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps