-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[processor/tailsampling] Improved "not sampled" decision cache usage #37189
[processor/tailsampling] Improved "not sampled" decision cache usage #37189
Conversation
…l map if their trace id is in a decision cache Signed-off-by: Sean Porter <portertech@gmail.com>
// IDs. If the trace ID is cached, it deletes the spans from the internal map. | ||
func (tsp *tailSamplingSpanProcessor) releaseNotSampledTrace(id pcommon.TraceID) { | ||
tsp.nonSampledIDCache.Put(id, true) | ||
_, ok := tsp.nonSampledIDCache.Get(id) |
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.
This Get()
would be unnecessary if the cache interface Put()
returned bool, error
. Saving for a potential future enhancement.
Signed-off-by: Sean Porter <portertech@gmail.com>
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.
The change looks sane, but perhaps it could include a new test case?
Signed-off-by: Sean Porter <portertech@gmail.com>
@@ -386,8 +385,7 @@ func TestLateArrivingSpanUsesDecisionCache(t *testing.T) { | |||
// The final decision SHOULD be Sampled. | |||
require.EqualValues(t, 1, nextConsumer.SpanCount()) | |||
|
|||
// Drop the trace to force cache to make decision | |||
tsp.dropTrace(traceID, time.Now()) |
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.
@jpkrohling I was able to reuse the existing decision tests for the new functionality 👍 It was meant to be 😄
…pen-telemetry#37189) Currently, a "not sampled" decision for a trace is only cached when late spans arrive for it. Whereas a "sampled" decision for a trace is immediately cached. This pull request immediately caches "not sampled" decisions, late spans (or reprocessed spans) for "not sampled" traces now take fewer resources to process. Currently, traces are stored in memory until `num_traces` is reached, then the oldest is deleted to make room. This is a clever mechanism to limit the size* of the internal map, however, trace span counts and their contents likely vary considerably. This pull request doesn't touch this mechanism, but it does delete traces from the internal map after they are released and are added to a decision cache. --------- Signed-off-by: Sean Porter <portertech@gmail.com>
Currently, a "not sampled" decision for a trace is only cached when late spans arrive for it. Whereas a "sampled" decision for a trace is immediately cached. This pull request immediately caches "not sampled" decisions, late spans (or reprocessed spans) for "not sampled" traces now take fewer resources to process.
Currently, traces are stored in memory until
num_traces
is reached, then the oldest is deleted to make room. This is a clever mechanism to limit the size* of the internal map, however, trace span counts and their contents likely vary considerably. This pull request doesn't touch this mechanism, but it does delete traces from the internal map after they are released and are added to a decision cache.