You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### Description
Fixes some of the metrics emitted from sampling decisions. I believe
`otelcol_processor_tail_sampling_sampling_trace_dropped_too_early` and
`otelcol_processor_tail_sampling_sampling_policy_evaluation_error_total`
are sometimes overcounted.
The bug: `samplingPolicyOnTick` creates a struct `policyMetrics` to hold
on to some counters. This struct is shared for all the traces that are
evaluated during that tick:
https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/22c647a3ae134697d90b67c45879227ea54d63be/processor/tailsamplingprocessor/processor.go#L324
Each loop, the values of the counters are added to the metrics:
https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/22c647a3ae134697d90b67c45879227ea54d63be/processor/tailsamplingprocessor/processor.go#L340-L344
But the counters are not reset in between loops, so if the first
evaluated trace could not be found this would set `idNotFoundOnMapCount`
to `1`.
Every loop after this will add `1` to
`otelcol_processor_tail_sampling_sampling_trace_dropped_too_early`
metric, even though the trace was found.
I've moved the metrics outside of the for loop so the counters are only
added once.
#### Testing
I have added a dedicated test for each metric processing multiple traces
in one tick.
~~I've a added a test for
`otelcol_processor_tail_sampling_sampling_trace_dropped_too_early`.
I can add one for `sampling_policy_evaluation_error` too, just not sure
how to deliberatly fail a policy.~~
# Use this changelog template to create an entry for release notes.
2
+
3
+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4
+
change_type: bug_fix
5
+
6
+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7
+
component: tailsamplingprocessor
8
+
9
+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10
+
note: Fixed sampling decision metrics `otelcol_processor_tail_sampling_sampling_trace_dropped_too_early` and `otelcol_processor_tail_sampling_sampling_policy_evaluation_error_total`, these were sometimes overcounted.
11
+
12
+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13
+
issues: [37212]
14
+
15
+
# (Optional) One or more lines of additional information to render under the primary note.
16
+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17
+
# Use pipe (|) for multiline entries.
18
+
subtext: |
19
+
As a result of this change non-zero values of `otelcol_processor_tail_sampling_sampling_trace_dropped_too_early`
20
+
and `otelcol_processor_tail_sampling_sampling_policy_evaluation_error_total` metrics will be lower.
21
+
Before this fix, errors got counted several times depending on the amount of traces being processed
22
+
that tick and where in the batch the error happened.
23
+
Zero values are unaffected.
24
+
25
+
# If your change doesn't affect end users or the exported elements of any package,
26
+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
27
+
# Optional: The change log or logs in which this entry should be included.
28
+
# e.g. '[user]' or '[user, api]'
29
+
# Include 'user' if the change is relevant to end users.
30
+
# Include 'api' if there is a change to a library API.
0 commit comments