Repository navigation
[CONFIGURATION] Build composable samplers from file configuration - #4366
Conversation
7289e33 to
0b042aa
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4366 +/- ##
==========================================
+ Coverage 81.79% 81.91% +0.13%
==========================================
Files 493 494 +1
Lines 19474 19654 +180
==========================================
+ Hits 15926 16097 +171
- Misses 3548 3557 +9
🚀 New features to boost your workflow:
|
…ly in sdk_builder_test.cc
dbarker
left a comment
There was a problem hiding this comment.
Thanks for the PR! Please see some initial feedback below.
dbarker
left a comment
There was a problem hiding this comment.
Thanks for the updates. Please see feedback below on the rule based predicate.
| : public opentelemetry::sdk::configuration::SamplerConfigurationVisitor | ||
| { | ||
| public: | ||
| // NOLINTBEGIN(misc-no-recursion) |
There was a problem hiding this comment.
The yaml schema supports infinite sampler nesting due to the ExperimentalComposableRuleBasedSampler containing an array of ExperimentalComposableRuleBasedSamplerRule which each may contain a ExperimentalComposableRuleBasedSampler (See: schema/tracer_provider.yaml#L340).
Without a limit to the sampler nesting depth, a misconfigured yaml file may cause excessive resource usage and latency given that the nested samplers will be run in the Tracer::StartSpan method on the hot path. We need some protection for this.
Please add a comment here to clarify why the recursion is accepted, a depth limit (10 seems reasonable), and throw a configuration error when the limit is hit.
There was a problem hiding this comment.
This can be a follow up PR and is not blocking
There was a problem hiding this comment.
Thank you! I will do a follow up PR.
There was a problem hiding this comment.
Thanks. Please hold on that PR. I'm integrating this PR into #4367 and may address there. The composable sampler builders will move out of the SdkBuilder in that PR so there would be conflicts.
dbarker
left a comment
There was a problem hiding this comment.
Nice work! Please see this comment for a follow up PR. I plan to merge once CI passes.
| bool match_span_kind_consumer = false; | ||
|
|
||
| // Significant digits used to format double attribute values for matching. | ||
| int double_precision = 6; |
There was a problem hiding this comment.
nit - this type should be std::uint32_t and ranged checked before use. Okay for followup PR
Fixes #4028
Follows up #4334, requested by @dbarker in #4334 (comment).
Schema reference https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema/tracer_provider.yaml
Changes
The composable visit methods in
SdkBuilderwere placeholders.always_on,always_off, andprobabilitybuilt the legacy samplers, andparent_thresholdandrule_basedignored their config and sampled everything. They now build the real composable samplers through a recursive visitor wrapped inCompositeSamplerFactory::Create, with a new predicate forrule_basedmatching (attribute values and patterns, span kinds, parent).The composable probability
ratiois now range checked at parse time, same as #4334, andComposableProbabilitySamplerguards against NaN instead of hittingstd::llround(NaN * 2^56).CHANGELOG.mdupdated for non-trivial changes