[processor/spanpruning] Add bytes metrics#49008
Open
portertech wants to merge 14 commits into
Open
Conversation
Signed-off-by: Sean Porter <portertech@gmail.com>
- getBytes: drop unused receiver (revive unused-receiver) and unused ctx param - TestBytesMetrics_MatchedEqualsReceivedWithNoConditions: use require.Positive (testifylint) - createTestTraceWithLeafSpans: drop always-constant spanName param (unparam)
csmarchbanks
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add serialized bytes metrics to span pruning processor
Description
This PR adds opt-in serialized byte-size telemetry to the span pruning processor, enabling users to measure the data-volume impact of pruning rather than just span counts. It builds on the existing core pruning, parent recursion, and aggregation metrics.
Changes
New feature: Bytes Metrics
Span-count metrics show how many spans were pruned, but not how much serialized data that saved. This feature serializes trace data with
ptrace.ProtoMarshalerand reports the byte sizes before and after pruning, for both the full batch and the matched subset of traces.Visibility is provided through four counter metrics (unit
By, monotonic, disabled by default):processor_spanpruning_bytes_received- full batch size before pruningprocessor_spanpruning_bytes_processed_input- matched subset size before pruningprocessor_spanpruning_bytes_processed_output- matched subset size after pruningprocessor_spanpruning_bytes_emitted- full batch size after pruningImplementation notes:
spanInfonow tracks itsResourceSpans(in addition toScopeSpans) so the newgetByteshelper can reconstruct the original RS/SS hierarchy when sizing a subset of traces.matchedTracesset is wired intoprocessTracesas a stand-in for future OTTLconditionsfiltering. Until conditions are supported in contrib, every trace is treated as matched, sobytes_processed_input == bytes_receivedandbytes_processed_output == bytes_emitted. The split is in place so the matched-subset metrics become meaningful once condition filtering lands.Configuration options:
When
enable_bytes_metricsisfalse, behavior is unchanged and no bytes metrics are emitted.Testing
bytes_processed_input == bytes_receivedandbytes_processed_output == bytes_emittedwhen no conditions are configuredmetadatatest)Documentation
Updated README with the
enable_bytes_metricsoption, the four new metrics, and a "Byte metrics semantics" section explaining valid comparisons now and the forward-looking behavior onceconditionssupport is added (including the case where aggregation summaries can makebytes_processed_outputexceedbytes_processed_input); added the four counters tometadata.yamland regenerated the telemetry code.