[SVLS-8169] feat: Support span dedup#939
Conversation
2071e2f to
d1dff83
Compare
|
|
||
| /// A deduplicator that maintains a fixed-size cache of recently seen IDs. | ||
| /// When the capacity is reached, the oldest ID is evicted (FIFO). | ||
| pub struct Deduper { |
There was a problem hiding this comment.
this deduper is based on span id. Is it guaranteed to be globally unique? ie. what if between 2 traces they happen to have the same span id?
There was a problem hiding this comment.
Good point. I didn't know two traces can have the same span id. Added trace id to dedup key.
|
|
||
| let stats_processor = Arc::new(stats_processor::ServerlessStatsProcessor {}); | ||
|
|
||
| // Deduper |
There was a problem hiding this comment.
These 1-line comments that just describe a single line of code feel a bit noisy. Can we remove them.
| /// Creates a new dedup service with the default capacity (50). | ||
| #[must_use] | ||
| pub fn new() -> (Self, DedupHandle) { | ||
| Self::with_capacity(50) |
There was a problem hiding this comment.
Don't think we need to let this be configurable, just always use the same size. Also, maybe worth bumping to 100? (non-blocking comment)
There was a problem hiding this comment.
I want to keep it for tests so I can set capacity to 3 to test eviction. But I'll remove pub. Let me know if you have a better alternative.
I don't have a strong idea on capacity. Will bump to 100.
|
Tianning's comment has been addressed. Bypass requirements to merge this PR. |
TL;DR
Problem
Node.js tracer sometimes sends duplicate traces to the extension, causing over-count of trace stats. In our tests, the over-count is usually 1–4 for 50, 500 or 5000 invocations. This only happens when the "default" flushing strategy (which uses the "continuous" strategy) is used, and doesn't happen when the "end" strategy is used.
Cause of problem
I think it's similar to a known problem of continuous flushing.
Testing
Steps
Result
Before:
After:
Options considered
This PR chooses 3 because it's the easiest.
Notes
Thanks @astuyve @rochdev @purple4reina for discussion.
Thanks Cursor for writing most of the code.
The under-count issue will be addressed separately.
Related issue: #688