Module: PlatformSdk::Observability::Langfuse::SpecSupport
- Defined in:
- lib/platform_sdk/observability/langfuse/spec_support.rb
Defined Under Namespace
Modules: TestHelpers
Constant Summary collapse
- DEFAULT_TEST_PUBLIC_KEY =
'pk-test'- DEFAULT_TEST_SECRET_KEY =
'sk-test'- DEFAULT_TEST_ENVIRONMENT =
'test'
Class Method Summary collapse
-
.apply!(app_name:, environment: DEFAULT_TEST_ENVIRONMENT) ⇒ Object
Configure the Langfuse module with a NullSpanExporter.
-
.exporter ⇒ Object
The currently-configured NullSpanExporter, or nil if ‘install!` was not called or the configuration was reset.
-
.install!(app_name:, environment: DEFAULT_TEST_ENVIRONMENT) ⇒ Object
Register the RSpec lifecycle hooks.
Class Method Details
.apply!(app_name:, environment: DEFAULT_TEST_ENVIRONMENT) ⇒ Object
Configure the Langfuse module with a NullSpanExporter. Separate from ‘install!` so it can be invoked directly in specs that need to test SpecSupport itself, or by apps that drive their own lifecycle.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/platform_sdk/observability/langfuse/spec_support.rb', line 49 def self.apply!(app_name:, environment: DEFAULT_TEST_ENVIRONMENT) ENV['LANGFUSE_PUBLIC_KEY'] ||= DEFAULT_TEST_PUBLIC_KEY ENV['LANGFUSE_SECRET_KEY'] ||= DEFAULT_TEST_SECRET_KEY PlatformSdk::Observability::Langfuse.reset! PlatformSdk::Observability::Langfuse.configure( app_name: app_name, environment: environment, exporter: NullSpanExporter.new ) end |
.exporter ⇒ Object
The currently-configured NullSpanExporter, or nil if ‘install!` was not called or the configuration was reset.
63 64 65 66 67 68 |
# File 'lib/platform_sdk/observability/langfuse/spec_support.rb', line 63 def self.exporter config = PlatformSdk::Observability::Langfuse.configuration return nil unless config config.exporter end |
.install!(app_name:, environment: DEFAULT_TEST_ENVIRONMENT) ⇒ Object
Register the RSpec lifecycle hooks. Call once from ‘rails_helper.rb` (or `spec_helper.rb`). The actual NullSpanExporter wiring happens in `before(:suite)`; this method just sets up the hooks.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/platform_sdk/observability/langfuse/spec_support.rb', line 29 def self.install!(app_name:, environment: DEFAULT_TEST_ENVIRONMENT) require 'rspec/core' RSpec.configure do |config| config.before(:suite) do PlatformSdk::Observability::Langfuse::SpecSupport.apply!( app_name: app_name, environment: environment ) end config.before(:each) do PlatformSdk::Observability::Langfuse::SpecSupport.exporter&.clear end config.include TestHelpers end end |