Shut the batch span processor down when the console one fails - #315
Shut the batch span processor down when the console one fails#315ayaangazali wants to merge 1 commit into
Conversation
LogfireSpanProcessor awaited the console processor before the wrapped one, so a console failure skipped the batch processor and dropped every span still queued for export. Settle both, rethrow a lone failure unchanged, raise several together.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
Merge Risk: ⚪ Minimal · up to Console processor failures no longer prevent the wrapped batch processor from flushing or shutting down, while lifecycle errors remain visible to callers. The change is ready to merge. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
LogfireSpanProcessoris the span processor the Node SDK installs by default (sdk.ts:391). It wraps theBatchSpanProcessorthat holds spans on their way to OTLP, and optionally a console processor. Both lifecycle methods awaited them in sequence:If the console call rejects, the second line never runs.
this.wrappedis the batch processor, and itsshutdownis what exports whatever is still queued, so the failure that skips it is exactly the moment those spans are lost.Against
main, with the console exporter'sshutdownrejecting:This repo has settled the same shape twice.
TailSamplingProcessor.runBothsays it directly:And f9dedfa gave
flushRuntimeandshutdownRuntimea shared settle-and-report seam for the same reason. This processor was not covered by either.The fix starts both calls, waits for both, rethrows a lone failure unchanged so the existing rejection contract is unaffected, and raises two as an
AggregateError. Waiting concurrently also stops a slow console flush from eating into the deadlineflushRuntimenow applies.Being straight about severity: I did not find an input that makes the console side reject on its own today.
LogfireConsoleSpanExporter.shutdownresolves, and the globalconsoleswallows write errors, so this is currently a contract gap rather than a live data loss. It matters because the console exporter is the replaceable, I/O-doing half of the pair and the batch processor is the half whose loss is unrecoverable, and because the two precedents above already decided this ordering is wrong.Built this with Claude Code's help and reviewed the diff myself.