JuliusBrussee/caveman · error

telemetry attributes exceed

Error message

telemetry attributes exceed %d bytes

What it means

SanitizeAttributes enforces telemetry span-attribute budgets: each attribute value must fit MaxAttributeValueBytes and the combined size of all keys+values must fit MaxAttributesBytes. When the running total crosses MaxAttributesBytes, the sanitizer fails closed and returns this error instead of emitting oversized span data.

Solutions

  1. Trim attribute values so the total of all keys+values stays under MaxAttributesBytes
  2. Drop low-value attributes (pivots, payloads) before calling SanitizeAttributes
  3. Truncate each value to MaxAttributeValueBytes and count the total yourself before the call
  4. Increase MaxAttributesBytes only if your backend truly supports larger spans

Example fix

// before
attrs["http.request.body"] = string(body) // huge
attrs["pivots"] = pivotsJSON
sanitized, err := SanitizeAttributes(attrs)
// after
sanitized, err := SanitizeAttributes(map[string]string{
	"http.status_code": code,
	"http.body.sha256": sha256hex(body), // bounded size
})
Defensive patterns

Strategy: validation

Validate before calling

const total = Object.entries(attrs).reduce((n,[k,v])=>n+k.length+v.length,0)
if (total > MaxAttributesBytes) {
  throw new Error(`attributes total ${total} exceeds ${MaxAttributesBytes} bytes`)
}

Type guard

function fitsBudget(attrs: Record<string,string>, max: number): boolean {
  return Object.entries(attrs).every(([k,v]) => v.length <= MaxAttributeValueBytes) &&
    Object.entries(attrs).reduce((n,[k,v])=>n+k.length+v.length,0) <= max
}

Prevention

When it happens

Trigger: Calling SanitizeAttributes (via Parse) with a map whose cumulative key+value byte length exceeds MaxAttributesBytes — e.g. many large attributes accumulated on a span before export.

Common situations: Instrumentation attaching request/response bodies or long error strings as span attributes; batch exporters aggregating too many attributes on one span; misconfigured telemetry pipelines that disable attribute truncation upstream.

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


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/85ef37941e6b9e91. Report an issue: GitHub.

Appendix: source

Thrown at shared/platform/telemetry/span.go:272

		}
	}
	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)