fix: Sampling Processor not removing higher level objs #1879
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.
Proposed Change
While testing the Sampling Processor I noticed that in BindPlane the 'Filter Debug Logs' processor recommendation was being recommended despite no debug logs being present.
After debugging, I discovered this was occurring because this processor only deleted log records, leaving behind the parent scope and resource level objects. This was causing these objects to be initialized with default values when they were technically empty.
This change cleans up these objects if they are effectively empty. So resource spans/metrics/logs are removed if there are no scope entries, and scope spans/metrics/logs are removed if there are no spans/metrics/logRecords present. This successfully removes the filter debug recommendation.
To test, add the following replace statements to the transform agent
go.mod
, and then configure local bindplane to use this build of the transform agent (or just use a remote bta with this build).Checklist