refactor(sampling): move the sampling logic from dd-trace-rs [APMSP-2946]#1927
Conversation
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
b244f7c to
c710521
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b244f7c989
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1927 +/- ##
==========================================
+ Coverage 71.88% 72.65% +0.76%
==========================================
Files 437 448 +11
Lines 71152 73570 +2418
==========================================
+ Hits 51150 53451 +2301
- Misses 20002 20119 +117
🚀 New features to boost your workflow:
|
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 89db307 | Docs | Datadog PR Page | Give us feedback! |
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
…ken loss (#215) # What does this PR do? Fixes for issues found in this [PR](DataDog/libdatadog#1927) while moving the sampling code to `libdatadog`. # Motivation Fix all the bugs Co-authored-by: bjorn.antonsson <bjorn.antonsson@datadoghq.com>
06ce6dd to
0b83000
Compare
There was a problem hiding this comment.
Do you know that there's already a rate limiter in libdd-common/src/rate_limiter.rs?
There was a problem hiding this comment.
Nope I didn't. Thanks. I'll look at it.
There was a problem hiding this comment.
It's by the way the limiter PHP uses, and is a sliding window rather than discrete windows.
There was a problem hiding this comment.
I had a dig through the specs for _dd.limit_psr and how it should be reported back to the agent, which is what this rate limiter is implementing, and I can't see how you could do that with the rate limiter in libdd-common.
There was a problem hiding this comment.
But, that's what the rate() function is for on the Limiter trait?
There was a problem hiding this comment.
They are not the same, and the RFC mandates tokenized buckets and not a sliding window.
0b83000 to
f108550
Compare
0bb5943 to
d30a3f2
Compare
d30a3f2 to
ce8315c
Compare
| /// Checks if the given subject matches the glob pattern | ||
| /// The match is case insensitive. | ||
| pub fn matches(&self, subject: &str) -> bool { | ||
| let subject_lower = subject.to_lowercase(); |
There was a problem hiding this comment.
to_lowercase() is going to allocate a new string on every match. Would it be more performant to use eq_ignore_ascii_case() when checking for a match below?
There was a problem hiding this comment.
As far as I can see there is nothing in the RFC that says that it should be ASCII. I'll save this optimization for a follow up PR.
ekump
left a comment
There was a problem hiding this comment.
Could you add a ticket to Jira for this?
Left some minor comments and performance concern trolling. Nothing blocking. LGTM.
| } | ||
|
|
||
| /// Represents a priority for sampling rules | ||
| #[allow(dead_code)] |
There was a problem hiding this comment.
I don't think you need to allow dead_code for a pub enum?
There was a problem hiding this comment.
It's only pub(crate), so it's needed (for now).
| .get("http.status_code") | ||
| .and_then(|f| { | ||
| let v = *f as u64; | ||
| (v > 0 && v <= u32::MAX as u64).then_some(v as u32) |
There was a problem hiding this comment.
| (v > 0 && v <= u32::MAX as u64).then_some(v as u32) | |
| u32::try_from(v).ok()? |
|
(PS: Given the size of the PR, I went fast on tests and benches) |
8a9a8ab to
c56620e
Compare
64c8403 to
493fd9e
Compare
493fd9e to
89db307
Compare
|
/merge |
|
View all feedbacks in Devflow UI.
This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
The expected merge time in
|
040260c
into
main
What does this PR do?
Moves the sampling logic from
dd-trace-rsso that it can be reused.Motivation
Reuse all the things.
Additional Notes
Has been tested and benchmarked with the code in
dd-trace-rs.How to test the change?
Unit tests and benchmarks are here.