Skip to content

feat(tracing): add metrics_reporter config option to surface BSP events - #99

Open
Alan-Marx wants to merge 6 commits into
simplepractice:mainfrom
Alan-Marx:feat/metrics-reporter
Open

feat(tracing): add metrics_reporter config option to surface BSP events#99
Alan-Marx wants to merge 6 commits into
simplepractice:mainfrom
Alan-Marx:feat/metrics-reporter

Conversation

@Alan-Marx

@Alan-Marx Alan-Marx commented Jul 28, 2026

Copy link
Copy Markdown

TL;DR

Adds a config.metrics_reporter to surface BatchSpanProcessor operational metrics (dropped spans, export failures, buffer utilization).

Why

The OTel BatchSpanProcessor already emits metrics through a pluggable reporter interface, but Langfuse::SpanProcessor never 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

  • Has label
  • Has linked issue
  • Tests added for new behavior
  • Docs updated (if user-facing)

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_reporter so apps can plug into the OpenTelemetry BatchSpanProcessor metrics interface (dropped spans, export success/failure, buffer utilization). Langfuse::SpanProcessor now passes config.metrics_reporter into the BSP constructor; when unset (default nil), behavior stays the same as today.

Configuration is validated in Config#validate! and OtelSetup (must implement add_to_counter and observe_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.

…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>
@Alan-Marx Alan-Marx changed the title feat(tracing): add metrics_reporter config option to surface BSP oper… feat(tracing): add metrics_reporter config option to surface BSP events Jul 28, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread lib/langfuse/otel_setup.rb
Alan Marx and others added 5 commits July 28, 2026 10:01
…_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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant