Skip to content

feat(flags): capture feature flag evaluations on spans #16485

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

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

aliu39
Copy link
Member

@aliu39 aliu39 commented Jun 4, 2025

Based off https://github.com/getsentry/sentry-python/pull/4280/files
Reopened from #16475

This PR updates our 5 browser FF integrations to capture flag evaluations on spans. This implementation avoids changes to the Span class, saving bundle size.

  • on eval, flags are buffered per-span in a global WeakMap.
  • the .on('spanEnd') hook is used to freeze the flags in the span attributes when the span finishes.
  • staying consistent with the python PR:
    • we only capture values for the first 10 unique flags per span. These are in order of last evaluation, but subsequent flags are dropped.
    • attribute keys have the format flag.evaluation.{flagKey}

From @AbhiPrasad :

A method on the span break our compat with OTEL spans, which we use for duck typing in some scenarios.

@aliu39
Copy link
Member Author

aliu39 commented Jun 5, 2025

@aliu39 aliu39 force-pushed the aliu/span-flags-v2 branch from 03699e5 to 7c2c161 Compare June 6, 2025 16:49
@aliu39 aliu39 marked this pull request as ready for review June 6, 2025 22:15
@aliu39 aliu39 requested a review from chargome June 6, 2025 22:15
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.

1 participant