class LittleGhost::Tracing::PayloadLimiter

Keeps span attributes within a byte budget before a tracing backend rejects or silently drops them. Captured model histories, Tool arguments, and Tool results can grow far beyond what an exporter accepts; a PayloadLimiter shortens them while keeping the parts a reader needs.

LittleGhost.configure do |config|
  config.instrument LittleGhost::Tracing::OpenTelemetry.new(
    payload_limiter: LittleGhost::Tracing::PayloadLimiter.new(max_bytes: 64_000)
  )
end

Only String attributes larger than max_bytes change. Message lists in gen_ai.input.messages and the OpenInference input.value keep the most recent messages that fit, plus a leading system or developer message when there is room. Output messages keep the leading choices. A Tool call and its result are kept or dropped together, so a preview never shows a result without its call. JSON values stay valid JSON, long strings keep their beginning and end around a ...[truncated]... marker, and multibyte characters are never split.

Each shortened attribute is recorded under telemetry_truncation in the OpenInference metadata attribute, with its original and captured sizes and, for message lists, how many messages were omitted. Existing metadata is preserved.

The limiter only shortens content that was already captured. It does not scrub or redact; configure Support::ContentCapture for that. A limiter holds no mutable state and can be shared across threads.