Skip to content

Trim large span attributes at record time to bound trace memory#85

Open
rubenvanassche wants to merge 1 commit into
mainfrom
span-attribute-byte-limit
Open

Trim large span attributes at record time to bound trace memory#85
rubenvanassche wants to merge 1 commit into
mainfrom
span-attribute-byte-limit

Conversation

@rubenvanassche

Copy link
Copy Markdown
Member

Query-heavy commands (e.g. thousands of bulk upsert()s) could accumulate multi-MB query spans in memory until the process hit memory_limit, since spans are retained for the whole trace and the existing ReportTrimmer only runs at send time. This adds a LargeAttributesTrimmingRecorder trait that, at record time, drops any string or array attribute exceeding a configurable byte budget (max_attribute_size_in_kb, default 32KB) using an allocation-free early-exit AttributeSizeLimiter, incrementing the OpenTelemetry droppedAttributesCount. Trimming is opt-in per recorder via shouldTrimAttributes() (off by default) and is enabled for QueryRecorder and GlowRecorder, covering both spans and span events. Scalars, bools, floats and enums are never touched, and 0 disables trimming. Downstream note: laravel-flare mirrors this trace-limits config and will need the same max_attribute_size_in_kb key added.

Bound retained trace memory by dropping oversized string/array attributes
per span/span-event via a configurable byte budget (max_attribute_size_in_kb,
default 32KB). Opt in per recorder; enabled for queries and glows.
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.

1 participant