Skip to content

feat(eap): Trim spans with new trimming processor#5616

Open
loewenheim wants to merge 20 commits intomasterfrom
sebastian/trim-eap-items
Open

feat(eap): Trim spans with new trimming processor#5616
loewenheim wants to merge 20 commits intomasterfrom
sebastian/trim-eap-items

Conversation

@loewenheim
Copy link
Contributor

This puts the new trimming processor into practice by enabling it for spans. It also introduces some necessary configuration:

  • A new max_removed_attribute_key_bytes (default 10KiB) that controls up to which limit Relay will store invalid/removed attribute keys.
  • A trimming section in the project config which (for now) allows configuring the maximum bytes size above which spans should be trimmed. If this is not set, spans will not be trimmed.
  • Field attributes on spans that exclude everything but attributes from trimming and size calculations.

ref: INGEST-732.

@loewenheim loewenheim requested a review from a team as a code owner February 5, 2026 12:35
@linear
Copy link

linear bot commented Feb 5, 2026

Comment on lines 194 to 200
let trimming_root_state = {
let mut attrs = FieldAttrs::default();
if let Some(span_config) = ctx.project_info.config().trimming.span {
attrs = attrs.max_bytes(span_config.max_size as usize);
}
ProcessingState::new_root(Some(Cow::Owned(attrs)), [])
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd really like to hide this in a utility or builder. I did something similar for the time normalization in processing/utils/normalize, could hide it there to create the processing state.

Or maybe a builder/better function to run the trimming alltogether.

Nothing important though, can also do that in a follow-up

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a TODO about this, my proposed PR for improving this is #5618.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you like it now @Dav1dde ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better! Just awkward formatting from rust formatter.

@loewenheim loewenheim force-pushed the sebastian/trim-eap-items branch from 71dd15b to b7f3288 Compare February 6, 2026 14:17
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

return Ok(());
}

// This counts the lengths of all attribute keys regardless of whether
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object trimming drops last remarked key via split_off

Medium Severity

The process_object split logic sets i = key.as_str() before the match and never advances it afterward, so split_off(&i) removes the last key that received WithRemark. In contrast, process_array and process_attributes both increment i after the match, correctly preserving remarked entries. When all remaining keys fit within removed_key_byte_budget, the final remarked key is silently dropped. This code was previously gated behind #[allow(unused)] and is now activated for span processing.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants