FEATURE: add Config#valid? and Langfuse.configured? - #98
Conversation
Adds a non-raising Config#valid? predicate that delegates to validate!, and a top-level Langfuse.configured? convenience method. Replaces the internal tracing_config_ready? helper with direct calls to configuration.valid? now that Config owns that logic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update CHANGELOG and CONFIGURATION docs for Config#valid? and Langfuse.configured?. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…OR_HANDLING Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Restore tracing-specific gating via Config#validate_tracing! so invalid cache/client settings can never disable tracing (parity with the Python and JS SDKs). Type-safe validators stop ArgumentError/NoMethodError leaking through Config#valid?, and batch_size/flush_interval are now validated before SpanProcessor consumes them. Reverts the in-PR version bump to keep the release flow with the release tooling. AAI-338
|
Pushed a revision (d887e03) implementing AAI-338 — keeps the new
Verified: 1369 specs green (96.91% coverage), rubocop clean, and a live end-to-end check — with valid credentials plus |
Deduplicate the public_key/secret_key/base_url trio shared by validate! and validate_tracing!, drop the redundant pre-validation in setup_tracing_if_ready (OtelSetup.setup already validates), and note the configured?-vs-tracing-readiness contract in YARD.
OtelSetup's setup/reuse logging now uses safe navigation, matching the guard in warn_tracing_disabled_once, so a nil logger can never crash tracing initialization or its degradation warning.
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.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 15911b7. Configure here.
| return if config.should_export_span.nil? || config.should_export_span.respond_to?(:call) | ||
|
|
||
| raise ConfigurationError, "should_export_span must respond to #call" | ||
| config.logger&.info("Langfuse tracing initialized with OpenTelemetry (#{mode} mode)") |
There was a problem hiding this comment.
Incomplete nil logger hardening
Medium Severity
Safe-navigation on config.logger lets OtelSetup.setup succeed when logger is nil, but SpanProcessor still calls @logger.error without nil-safety when should_export_span raises. That turns the intended span-drop path into a NoMethodError during finish. This is easy to hit because Config#default_logger can return a nil Rails.logger.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 15911b7. Configure here.


TL;DRIntroduces non-raising
Langfuse.configured?andLangfuse::Config#valid?methods.WhyLangfuse might not be configured in all application environments. Application code therefore needs a way to check whether an operation should be wrapped in a Langfuse observation or not. The only way to do that at the moment is to manually check ENV vars or call Langfuse.configuration.validate! and rescue the call.
This PR adds some new convenience methods to make these guards easier to write:
ChecklistNote
Medium Risk
Changes when tracing starts vs when the API client validates, and alters failure modes for misconfigured export settings; behavior is covered by new specs but affects observability in production.
Overview
Adds
Config#valid?andLangfuse.configured?so apps can guard Langfuse usage without rescuingConfigurationError. These reflect client config validity (credentials, cache, timeouts, etc.), not whether tracing can start.Validation is split and tightened:
validate!now uses shared type-aware helpers so bad types (e.g. string timeouts, non-string keys, boguscache_stale_ttl) raiseConfigurationErrorinstead ofArgumentError/NoMethodError.validate_tracing!is a separate, narrower check (credentials,should_export_span,batch_size,flush_interval) used when OTel setup runs; invalid client-only settings no longer block tracing, and invalidbatch_size/flush_intervalno longer fail full client validation.Tracing behavior: lazy setup calls
validate_tracing!viaOtelSetup; failures onobserve/start_observationemit a one-time warning naming the bad setting and use a no-op tracer (safe withnillogger).Langfuse.tracer_providerstill raises, with messages prefixed by “Langfuse tracing is disabled: …”. Docs and changelog updated to describe the distinction between configured vs tracing-ready.Reviewed by Cursor Bugbot for commit 15911b7. Bugbot is set up for automated code reviews on this repo. Configure here.