Class: Langfuse::OtelExporter
- Inherits:
-
Object
- Object
- Langfuse::OtelExporter
- Defined in:
- lib/langfuse/otel_exporter.rb
Overview
Converts batched Langfuse events into OTLP/HTTP JSON (ExportTraceServiceRequest) and sends them to the Langfuse OTEL endpoint for v4-compatible ingestion.
Constant Summary collapse
- OTEL_ENDPOINT =
'/api/public/otel/v1/traces'
Instance Method Summary collapse
-
#export(events) ⇒ Faraday::Response
Export a batch of Langfuse events as OTLP spans.
-
#initialize(connection:, debug: false) ⇒ OtelExporter
constructor
A new instance of OtelExporter.
Constructor Details
#initialize(connection:, debug: false) ⇒ OtelExporter
Returns a new instance of OtelExporter.
14 15 16 17 |
# File 'lib/langfuse/otel_exporter.rb', line 14 def initialize(connection:, debug: false) @connection = connection @debug = debug end |
Instance Method Details
#export(events) ⇒ Faraday::Response
Export a batch of Langfuse events as OTLP spans.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/langfuse/otel_exporter.rb', line 22 def export(events) resource_spans = build_resource_spans(events) payload = { resourceSpans: resource_spans } puts "OTEL export payload: #{JSON.pretty_generate(payload)}" if @debug @connection.post(OTEL_ENDPOINT) do |req| req.headers['Content-Type'] = 'application/json' req.body = JSON.generate(payload) end end |