fix(sdk): stop span-attribute overflow from evicting trace references - #5206
Conversation
A playground agent run's root span floods past OTel's default 128-attribute limit because the resolved agent config (tools with full JSON schemas) flattens into one attribute per leaf. BoundedAttributes evicts the oldest attributes on overflow, which are exactly the ag.refs.* references stamped at span start, so traces silently lose their application/variant/revision links. Two guards: raise the span attribute limit to 256 (double the OTel default) via SpanLimits on the TracerProvider, and cap the root-span configuration flattening at depth 3 so each config section lands as one @ag.type=json: attribute instead of hundreds of leaves.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughTracing instrumentation now limits nested configuration metadata to three levels and configures the OpenTelemetry tracer provider to retain at most 256 span attributes. ChangesTracing attribute limits
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Symptom
Playground agent runs stopped showing any references (application / variant / revision) on their traces, even though the frontend forwards them correctly since #5163/#5179.
Cause
The root agent span records the resolved configuration flattened one attribute per leaf (
ag.meta.configuration.agent.tools.16.input_schema.properties.message.type, ...). A resolved agent config now carries ~17 tools with full JSON schemas, so the span blows past OTel's default 128 span-attribute limit.BoundedAttributessilently evicts the oldest attributes on overflow, and the oldest are exactly theag.refs.*references stamped at span start. Small-config runs (triggers) kept their references; playground runs lost them.Verified live on the dev stack: the broken root span holds exactly 128 attributes with zero
ag.refs.*, while a small trigger run seconds earlier holds 43 and keeps them.Fix
Two independent guards:
SpanLimits(max_attributes=256)on theTracerProvider(double the OTel default).max_depth=3, so each config section lands as one@ag.type=json:attribute (configuration.agent.tools,.llm,.instructions) instead of hundreds of leaves. Same mechanismdata.inputsalready uses.Before / after (live dev stack, same playground app)
Before: root span
referencescolumn NULL, noag.refs.*attributes,ag.flagsalso evicted.After: root span carries all three reference families (application, application_variant, application_revision v1) plus flags; ingestion populates the
referencescolumn again.SDK unit suite: the only failures are the documented pre-existing base reds (secrets SSRF x6, sdk permission-defaults x2, one QA replay), reproduced identically with the change reverted.
https://claude.ai/code/session_01QSwVMKwo4FBZXkeTd4t3SP