feat(tracing): add metrics_reporter config option to surface BSP events - #99
Open
Alan-Marx wants to merge 6 commits into
Open
feat(tracing): add metrics_reporter config option to surface BSP events#99Alan-Marx wants to merge 6 commits into
Alan-Marx wants to merge 6 commits into
Conversation
…ational metrics Forwards a user-supplied reporter to the underlying BatchSpanProcessor so consumers can observe dropped spans, export failures, buffer utilization, and other operational counters that the BSP emits but previously discarded. Defaults to nil, which preserves the OTel SDK's existing no-op behaviour — zero change for current users. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4058dbe. Configure here.
…_config! Module-level tracing skips Config#validate!, so an invalid reporter would pass setup and raise later when the BSP emits metrics. Mirrors the existing should_export_span dual-validation pattern. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…_metrics_reporter! Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…_metrics_reporter! Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…xplicit per-method raises Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…reporter validations Both validate_metrics_reporter! (Config) and validate_tracing_metrics_reporter! (OtelSetup) now use the same guard clause form for the observe_value check, removing the Style/GuardClause disable directives. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

TL;DR
Adds a
config.metrics_reporterto surface BatchSpanProcessor operational metrics (dropped spans, export failures, buffer utilization).Why
The OTel
BatchSpanProcessoralready emits metrics through a pluggable reporter interface, butLangfuse::SpanProcessornever forwarded one — so otel.bsp.dropped_spans and friends were silently discarded. Under queue pressure there was no way for consumers to know spans were being lost. This wires up the existing OTel hook so applications can observe back-pressure and data loss without patching the SDK.The default is nil, which makes the BSP fall back to its own built-in no-op reporter — zero behaviour change for current users.
Checklist
Note
Low Risk
Optional observability hook with nil default; only affects tracing setup validation and BSP constructor args, not export or span logic.
Overview
Adds optional
config.metrics_reporterso apps can plug into the OpenTelemetryBatchSpanProcessormetrics interface (dropped spans, export success/failure, buffer utilization).Langfuse::SpanProcessornow passesconfig.metrics_reporterinto the BSP constructor; when unset (defaultnil), behavior stays the same as today.Configuration is validated in
Config#validate!andOtelSetup(must implementadd_to_counterandobserve_value), included in the tracing config snapshot, and documented with a StatsD-style example and metric table.Reviewed by Cursor Bugbot for commit 6cf00dd. Bugbot is set up for automated code reviews on this repo. Configure here.