Repository navigation
[CONFIGURATION] Build composable samplers from file configuration #4366
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
dbarker
merged 13 commits into
open-telemetry:main
from
ayush-that:composable-sampler-plumbing
Aug 7, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0b042aa
Build composable samplers from file configuration
ayush-that fae6553
Include nostd/utility.h and composable_sampler_configuration.h direct…
ayush-that 7753a55
Move RuleBasedPredicate into trace samplers and share ratio validatio…
ayush-that d6bc791
Fix iwyu and clang-tidy findings from the local gate runs
ayush-that f5864e3
Merge branch 'main' into composable-sampler-plumbing
ayush-that a495515
Merge branch 'main' into composable-sampler-plumbing
ayush-that d23f0fe
Format attribute values into a stack buffer and test every attribute …
ayush-that 4a9202a
Format doubles with a single snprintf at a tunable precision defaulti…
ayush-that 7e5b55f
Merge branch 'main' into composable-sampler-plumbing
ayush-that 06732ea
Include nostd/variant.h directly
ayush-that b29a20a
Merge branch 'main' into composable-sampler-plumbing
ayush-that 0213ca1
Merge branch 'main' into composable-sampler-plumbing
ayush-that 1959086
Merge branch 'main' into composable-sampler-plumbing
dbarker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
80 changes: 80 additions & 0 deletions
80
sdk/include/opentelemetry/sdk/trace/samplers/rule_based_predicate.h
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "opentelemetry/sdk/trace/samplers/predicate.h" | ||
| #include "opentelemetry/trace/span_context.h" | ||
| #include "opentelemetry/trace/span_metadata.h" | ||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace trace | ||
| { | ||
|
|
||
| /** | ||
| * Matching criteria for RuleBasedPredicate. A criteria group left at its | ||
| * default is inactive and matches every span. | ||
| */ | ||
| struct RuleBasedPredicateOptions | ||
| { | ||
| bool match_values = false; | ||
| std::string values_key; | ||
| std::vector<std::string> values; | ||
|
|
||
| bool match_patterns = false; | ||
| std::string patterns_key; | ||
| std::vector<std::string> included; | ||
| std::vector<std::string> excluded; | ||
|
|
||
| bool match_parent_none = false; | ||
| bool match_parent_remote = false; | ||
| bool match_parent_local = false; | ||
|
|
||
| bool match_span_kind_internal = false; | ||
| bool match_span_kind_server = false; | ||
| bool match_span_kind_client = false; | ||
| bool match_span_kind_producer = false; | ||
| bool match_span_kind_consumer = false; | ||
|
|
||
| // Significant digits used to format double attribute values for matching. | ||
| int double_precision = 6; | ||
| }; | ||
|
|
||
| /** | ||
| * RuleBasedPredicate matches a span when every active criteria group in its | ||
| * options matches: parent kind, span kind, an attribute equal to one of the | ||
| * given values, and an attribute matching the included/excluded wildcard | ||
| * patterns (excluded wins). Non-string attributes are matched by their string | ||
| * representation; doubles are formatted with %g at double_precision significant | ||
| * digits, so 404.0 matches "404". | ||
| */ | ||
| class RuleBasedPredicate : public Predicate | ||
| { | ||
| public: | ||
| explicit RuleBasedPredicate(RuleBasedPredicateOptions options); | ||
|
|
||
| bool SpanMatches( | ||
| const opentelemetry::trace::SpanContext &parent_context, | ||
| nostd::string_view name, | ||
| opentelemetry::trace::SpanKind span_kind, | ||
| const opentelemetry::common::KeyValueIterable &attributes, | ||
| const opentelemetry::trace::SpanContextKeyValueIterable &links) const noexcept override; | ||
|
|
||
| nostd::string_view GetDescription() const noexcept override; | ||
|
|
||
| private: | ||
| bool ParentMatches(const opentelemetry::trace::SpanContext &parent_context) const noexcept; | ||
| bool SpanKindMatches(opentelemetry::trace::SpanKind span_kind) const noexcept; | ||
|
|
||
| RuleBasedPredicateOptions options_; | ||
| }; | ||
|
|
||
| } // namespace trace | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - this type should be std::uint32_t and ranged checked before use. Okay for followup PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.