{"record":{"id":"85ef37941e6b9e91","repo":"JuliusBrussee/caveman","slug":"telemetry-attributes-exceed-d-bytes","errorCode":null,"errorMessage":"telemetry attributes exceed %d bytes","messagePattern":"telemetry attributes exceed (.+?) bytes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/telemetry/span.go","lineNumber":272,"sourceCode":"\t\t}\n\t}\n\tif len(keys) > MaxAttributes {\n\t\treturn nil, fmt.Errorf(\"telemetry attributes exceed %d keys\", MaxAttributes)\n\t}\n\tsort.Strings(keys)\n\tout := make(map[string]string, len(keys))\n\ttotal := 0\n\tfor _, key := range keys {\n\t\tvalue := attrs[key]\n\t\tif len(key) > MaxAttributeKeyBytes {\n\t\t\treturn nil, fmt.Errorf(\"telemetry attribute key exceeds %d bytes\", MaxAttributeKeyBytes)\n\t\t}\n\t\tif len(value) > MaxAttributeValueBytes {\n\t\t\treturn nil, fmt.Errorf(\"telemetry attribute %q exceeds %d bytes\", key, MaxAttributeValueBytes)\n\t\t}\n\t\ttotal += len(key) + len(value)\n\t\tif total > MaxAttributesBytes {\n\t\t\treturn nil, fmt.Errorf(\"telemetry attributes exceed %d bytes\", MaxAttributesBytes)\n\t\t}\n\t\tout[key] = value\n\t}\n\treturn out, nil\n}\n","sourceCodeStart":254,"sourceCodeEnd":278,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/telemetry/span.go#L254-L278","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Trim attribute values so the total of all keys+values stays under MaxAttributesBytes","Drop low-value attributes (pivots, payloads) before calling SanitizeAttributes","Truncate each value to MaxAttributeValueBytes and count the total yourself before the call","Increase MaxAttributesBytes only if your backend truly supports larger spans"],"exampleFix":"// before\nattrs[\"http.request.body\"] = string(body) // huge\nattrs[\"pivots\"] = pivotsJSON\nsanitized, err := SanitizeAttributes(attrs)\n// after\nsanitized, err := SanitizeAttributes(map[string]string{\n\t\"http.status_code\": code,\n\t\"http.body.sha256\": sha256hex(body), // bounded size\n})","handlingStrategy":"validation","validationCode":"const total = Object.entries(attrs).reduce((n,[k,v])=>n+k.length+v.length,0)\nif (total > MaxAttributesBytes) {\n  throw new Error(`attributes total ${total} exceeds ${MaxAttributesBytes} bytes`)\n}","typeGuard":"function fitsBudget(attrs: Record<string,string>, max: number): boolean {\n  return Object.entries(attrs).every(([k,v]) => v.length <= MaxAttributeValueBytes) &&\n    Object.entries(attrs).reduce((n,[k,v])=>n+k.length+v.length,0) <= max\n}","tryCatchPattern":null,"preventionTips":["Hash or summarize large payloads instead of embedding them as attribute values","Keep a small allowlist of span attribute keys","Truncate values defensively before aggregating into spans"],"tags":["telemetry","size-limit","validation"],"backgroundTag":"payload-too-large","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}