Skip to content

SpanProcessor with better Sampler #902

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

Merged
merged 5 commits into from
Jun 17, 2025
Merged

Conversation

solnic
Copy link
Collaborator

@solnic solnic commented Jun 4, 2025

This is re-adding what #875 added but we had to revert it for 10.10.0 "emergency" release with OTP-28 fixes.

This will includes a better sampler via #903 and support for traces_sampler option via #910.

solnic added 2 commits June 10, 2025 13:28
* Better span sampler

This updates OpenTelemetry.Sampler so that it uses
`traces_sample_rate` for sampling spans before they
get sent to the span processor.

This way we're not processing spans when they are
dropped during sampling, which was previously the
case as the Client was responsible for sampling
just before attemping to send a transaction.

* Enhance sampling logic to record discarded transactions

* Clarify trace-level sampling decision-making

Previously it incorrectly referred to "parent" where
in reality we're dealing with spans from the same
trace and respect sampling decisions that were
already made for a given trace.

This is not the same thing as parent/child spans
that we're handling in the SpanProcessor as this
type of relationship is established post-sampling.

* Remove unnecessary sleep calls in sampler tests

* Fix flaky test

* Clean up make_sampling_decision

* Simplify client reports for dropped transactions

* Update traces_sample_rate default value to be nil

* Account for `nil` sample_rate when sampling

* Use put_test_config

* Update traces_sample_rate spec to allow nil value
@solnic solnic force-pushed the span-processor-with-new-sampler branch from d6af772 to 58ce111 Compare June 10, 2025 13:29
* Add support for `traces_sampler` config option

* Update docs

* Remove unnecessary attribute merging

* Call traces_sampler only for root spans

* Reuse sampling decision logic

* Add test for handling invalid traces_sampler return values

* Add tests for SamplingContext access functions
@solnic solnic force-pushed the span-processor-with-new-sampler branch from 56a0ca8 to aedc326 Compare June 17, 2025 11:03
@solnic solnic marked this pull request as ready for review June 17, 2025 11:05
@solnic solnic requested a review from sl0thentr0py June 17, 2025 11:05
@solnic solnic merged commit 8ded98a into master Jun 17, 2025
10 checks passed
@solnic solnic deleted the span-processor-with-new-sampler branch June 17, 2025 12:33
@solnic solnic restored the span-processor-with-new-sampler branch June 17, 2025 14:16
@solnic solnic deleted the span-processor-with-new-sampler branch June 17, 2025 14: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.

2 participants