JuliusBrussee/caveman · error
telemetry attribute exceeds bytes
Error message
telemetry attribute %q exceeds %d bytes
What it means
SanitizeAttributes enforces per-value and total byte budgets for span attributes. This specific error fires when a single attribute value exceeds MaxAttributeValueBytes; a sibling error covers the aggregate total exceeding MaxAttributesBytes. It fails closed rather than truncating the value.
Solutions
- Truncate the value before setting it (e.g. cap at 256 bytes with an ellipsis marker).
- Store a digest/ID and keep the full payload in logs or object storage.
- Split oversized payloads across dedicated log events rather than span attributes.
- Audit instrumentation for places that serialize whole objects into attribute values.
Example fix
// before
attrs["http.response.body"] = string(fullResponseBody) // often > limit
// after
body := string(fullResponseBody)
if len(body) > 256 { body = body[:256] + "...[truncated]" }
attrs["http.response.body"] = body Defensive patterns
Strategy: validation
Validate before calling
for k, v := range attrs {
if len(v) > maxAttrValueBytes /* mirror MaxAttributeValueBytes */ {
attrs[k] = truncate(v, maxAttrValueBytes)
}
} Try / catch
sanitized, err := telemetry.SanitizeAttributes(raw)
if err != nil && strings.Contains(err.Error(), "exceeds") && strings.Contains(err.Error(), "bytes") {
raw = truncateValues(raw, maxAttrValueBytes)
sanitized, err = telemetry.SanitizeAttributes(raw)
} Prevention
- Truncate large payloads (bodies, stack traces) at capture time, with an explicit marker.
- Store references (IDs, log keys) instead of full payloads in attributes.
- Also mind the aggregate MaxAttributesBytes budget across all key/value pairs.
- Add unit tests asserting attribute sizes stay under limits.
When it happens
Trigger: Parse called on a span where attrs[key] has a byte length greater than MaxAttributeValueBytes — e.g. dumping an entire HTTP response body, stack trace, or serialized JSON payload into one attribute.
Common situations: Recording full request/response bodies as attributes; storing large exception stack traces; accidentally passing an entire config blob instead of a summary.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- telemetry attribute key exceeds
- telemetry attributes exceed
- bounded
- cave_budget_release_exceeds_max
- eval evidence batch exceeds 1000 records
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/aa8808fee0d0a702.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/telemetry/span.go:268
keys := make([]string, 0, len(attrs))
for key := range attrs {
if AttributeAllowed(key) {
keys = append(keys, key)
}
}
if len(keys) > MaxAttributes {
return nil, fmt.Errorf("telemetry attributes exceed %d keys", MaxAttributes)
}
sort.Strings(keys)
out := make(map[string]string, len(keys))
total := 0
for _, key := range keys {
value := attrs[key]
if len(key) > MaxAttributeKeyBytes {
return nil, fmt.Errorf("telemetry attribute key exceeds %d bytes", MaxAttributeKeyBytes)
}
if len(value) > MaxAttributeValueBytes {
return nil, fmt.Errorf("telemetry attribute %q exceeds %d bytes", key, MaxAttributeValueBytes)
}
total += len(key) + len(value)
if total > MaxAttributesBytes {
return nil, fmt.Errorf("telemetry attributes exceed %d bytes", MaxAttributesBytes)
}
out[key] = value
}
return out, nil
}
View on GitHub (pinned to 3ee70a1026)