Module: PlatformSdk::Observability::Langfuse::SpecSupport::TestHelpers

Defined in:
lib/platform_sdk/observability/langfuse/spec_support.rb

Instance Method Summary collapse

Instance Method Details

#langfuse_exported_spansObject

Force-flush the BatchSpanProcessor and return every span the NullSpanExporter has captured during the current example. Use this to assert that a code path produced the expected spans.

Example:

spans = langfuse_exported_spans
parent = spans.find { |s| s.name == 'MyJob' }
expect(parent.attributes['langfuse.trace.tags']).to include('test')


79
80
81
82
83
# File 'lib/platform_sdk/observability/langfuse/spec_support.rb', line 79

def langfuse_exported_spans
  config = PlatformSdk::Observability::Langfuse.configuration
  config.tracer_provider.force_flush(timeout: 5)
  PlatformSdk::Observability::Langfuse::SpecSupport.exporter.exported_spans
end