Skip to content
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

Implement extended sampling #2384

Merged
merged 5 commits into from
Dec 12, 2023
Merged

Implement extended sampling #2384

merged 5 commits into from
Dec 12, 2023

Conversation

bwoebi
Copy link
Collaborator

@bwoebi bwoebi commented Nov 22, 2023

Description

  • Support for tags and resources in sampling rules
  • Allows looking at arbitrary spans too, not only root spans
  • Sampling rules now use glob pattern matching

Sampling rules use glob pattern matching
We used to have regexes, so it would be a breaking change. To work around this, we add a new DD_TRACE_SAMPLING_RULES_FORMAT parameter. This parameter allows regex and glob. regex is the default for retrocompatibility reasons. That said we will drop this parameter in 1.0.

Glob matching algo
It already existed for single spans sampling. So we're just factorizing some code. The previous algo had a small bug so there's one commit dedicated to this fix.

Readiness checklist

  • (only for Members) Changelog has been added to the release document.
  • Tests added for this feature/bug.

Reviewer checklist

  • Appropriate labels assigned.
  • Milestone is set.
  • Changelog has been added to the release document. For community contributors the reviewer is in charge of this task.

@bwoebi bwoebi added this to the 0.95.0 milestone Nov 22, 2023
@bwoebi bwoebi requested a review from a team as a code owner November 22, 2023 13:47
Copy link
Contributor

@PROFeNoM PROFeNoM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with respect to the RFC 👍

Comment on lines +9 to +10
bool dd_rule_matches(zval *pattern, zval *prop, int rulesFormat);
bool dd_glob_rule_matches(zval *pattern, zend_string* value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it, I may have put them in compat_string.[h|c], not to do an additional #include in priority_sampling.c, but this may be irrelevant 🤷

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the will not to do additional includes, but compat_string seems not to be the good placeholder for this. As rule matching as nothing to see with string compatibility.
I could move to a dedicated file if we believe it's not meant in ddshared, but it wouldn't solve the extra incude part of the comment

bwoebi and others added 5 commits December 12, 2023 14:48
Support for tags and resources in sampling rules
Allows looking at arbitrary spans too, not only root spans

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Sampling rules now use glob pattern matching. We used to have regexes, so it's a breaking change.

To work around this, we add a new DD_TRACE_SAMPLING_RULES_FORMAT parameter. This parameter allows `regex` and  `glob`. `regex` is the default for retrocompatibility reasons.

That said we will drop this parameter in 1.0.

Glob matching was already implemented for single span samplling so I just factorized some code.
There was one issue when you were using only `?`.
I've added a circuit break that fixes that issue and also improve the perf of the algo in the case of patterns with no `*` and shorter than the length of the input string.
We test that sampling works on resources with the same glob patterns

Also adds a test where we test all criterias in one sampling rule.
@pierotibou pierotibou merged commit b7a55c5 into master Dec 12, 2023
569 checks passed
@pierotibou pierotibou deleted the bob/extended-sampling branch December 12, 2023 19:05
@pierotibou pierotibou added this to the 0.96.0 milestone Dec 12, 2023
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.

None yet

3 participants