langfuse-rb 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/lib/langfuse/config.rb +3 -2
- data/lib/langfuse/otel_setup.rb +20 -13
- data/lib/langfuse/span_processor.rb +4 -3
- data/lib/langfuse/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d6fba08995eafb09635b4825f3295730326f9cbcaacbe6914311fbcd9bb54c2d
|
|
4
|
+
data.tar.gz: e10b412642da2ee0a0dad027f20b72052b80d872b000091a310c2aeb505cb5b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f1a0901369bba61664e00c6ab145b9227d7cf51e3e5a6c1371aa138c113c99d7a6a6e328166468900d51b9e6edeb4971855426fbd13e9c2b98a518fac2eb8380
|
|
7
|
+
data.tar.gz: 0f0a2895156d25673254a80256553f01d00724036dc2fd487ba8a2fededb424fb0adf54a45bb5547c17f20ee54d2be78d850e8cabe211256564b9d512121a665
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.12.2] - 2026-09-04
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- Forward OTLP exporter metrics to the configured metrics reporter (#117).
|
|
14
|
+
|
|
10
15
|
## [0.12.1] - 2026-09-03
|
|
11
16
|
|
|
12
17
|
### Fixed
|
|
@@ -178,7 +183,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
178
183
|
- Migrated from legacy ingestion API to OTLP endpoint
|
|
179
184
|
- Removed `tracing_enabled` configuration flag (#2)
|
|
180
185
|
|
|
181
|
-
[Unreleased]: https://github.com/simplepractice/langfuse-rb/compare/v0.12.
|
|
186
|
+
[Unreleased]: https://github.com/simplepractice/langfuse-rb/compare/v0.12.2...HEAD
|
|
187
|
+
[0.12.2]: https://github.com/simplepractice/langfuse-rb/compare/v0.12.1...v0.12.2
|
|
182
188
|
[0.12.1]: https://github.com/simplepractice/langfuse-rb/compare/v0.12.0...v0.12.1
|
|
183
189
|
[0.12.0]: https://github.com/simplepractice/langfuse-rb/compare/v0.11.0...v0.12.0
|
|
184
190
|
[0.11.0]: https://github.com/simplepractice/langfuse-rb/compare/v0.10.1...v0.11.0
|
data/lib/langfuse/config.rb
CHANGED
|
@@ -113,8 +113,9 @@ module Langfuse
|
|
|
113
113
|
attr_accessor :mask_otel_spans
|
|
114
114
|
|
|
115
115
|
# @return [#add_to_counter, #record_value, #observe_value, nil] Reporter for
|
|
116
|
-
# OpenTelemetry batch
|
|
117
|
-
# thread-safe, and nonblocking. The application owns its
|
|
116
|
+
# OpenTelemetry batch processor and OTLP exporter metrics. The reporter
|
|
117
|
+
# must be fast, thread-safe, and nonblocking. The application owns its
|
|
118
|
+
# lifecycle.
|
|
118
119
|
attr_accessor :metrics_reporter
|
|
119
120
|
|
|
120
121
|
# @return [#export, #force_flush, #shutdown, nil] Span exporter used by
|
data/lib/langfuse/otel_setup.rb
CHANGED
|
@@ -5,6 +5,7 @@ require "opentelemetry/exporter/otlp"
|
|
|
5
5
|
require "base64"
|
|
6
6
|
require_relative "masking_exporter"
|
|
7
7
|
require_relative "trace_export_guard"
|
|
8
|
+
require_relative "resilient_metrics_reporter"
|
|
8
9
|
|
|
9
10
|
module Langfuse
|
|
10
11
|
# OpenTelemetry initialization and setup for Langfuse tracing.
|
|
@@ -112,33 +113,39 @@ module Langfuse
|
|
|
112
113
|
end
|
|
113
114
|
|
|
114
115
|
def build_tracer_provider(config)
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
metrics_reporter = wrap_metrics_reporter(config)
|
|
117
|
+
exporter = build_exporter(config, metrics_reporter: metrics_reporter)
|
|
118
|
+
processor = SpanProcessor.new(
|
|
119
|
+
config: config,
|
|
120
|
+
exporter: TraceExportGuard.new(delegate: exporter, config: config),
|
|
121
|
+
metrics_reporter: metrics_reporter
|
|
117
122
|
)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
)
|
|
123
|
-
)
|
|
124
|
-
provider
|
|
123
|
+
|
|
124
|
+
OpenTelemetry::SDK::Trace::TracerProvider
|
|
125
|
+
.new(sampler: build_sampler(config.sample_rate))
|
|
126
|
+
.tap { |provider| provider.add_span_processor(processor) }
|
|
125
127
|
end
|
|
126
128
|
|
|
127
|
-
def build_exporter(config)
|
|
128
|
-
exporter = config.span_exporter || build_otlp_exporter(config)
|
|
129
|
+
def build_exporter(config, metrics_reporter:)
|
|
130
|
+
exporter = config.span_exporter || build_otlp_exporter(config, metrics_reporter: metrics_reporter)
|
|
129
131
|
return exporter unless config.mask_otel_spans
|
|
130
132
|
|
|
131
133
|
MaskingExporter.new(delegate: exporter, hook: config.mask_otel_spans, logger: config.logger)
|
|
132
134
|
end
|
|
133
135
|
|
|
134
|
-
def build_otlp_exporter(config)
|
|
136
|
+
def build_otlp_exporter(config, metrics_reporter:)
|
|
135
137
|
OpenTelemetry::Exporter::OTLP::Exporter.new(
|
|
136
138
|
endpoint: "#{config.base_url}/api/public/otel/v1/traces",
|
|
137
139
|
headers: build_headers(config.public_key, config.secret_key),
|
|
138
|
-
compression: "gzip"
|
|
140
|
+
compression: "gzip",
|
|
141
|
+
metrics_reporter: metrics_reporter
|
|
139
142
|
)
|
|
140
143
|
end
|
|
141
144
|
|
|
145
|
+
def wrap_metrics_reporter(config)
|
|
146
|
+
ResilientMetricsReporter.wrap(config.metrics_reporter, logger: config.logger)
|
|
147
|
+
end
|
|
148
|
+
|
|
142
149
|
def log_initialized(config)
|
|
143
150
|
mode = config.tracing_async ? "async" : "sync"
|
|
144
151
|
config.logger.info("Langfuse tracing initialized with OpenTelemetry (#{mode} mode)")
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "opentelemetry/sdk"
|
|
4
|
-
require_relative "resilient_metrics_reporter"
|
|
5
4
|
|
|
6
5
|
module Langfuse
|
|
7
6
|
# Batch span processor that owns Langfuse's enrichment and export filtering.
|
|
@@ -10,7 +9,9 @@ module Langfuse
|
|
|
10
9
|
class SpanProcessor < OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor
|
|
11
10
|
# @param config [Langfuse::Config] SDK configuration used for defaults and filtering
|
|
12
11
|
# @param exporter [#export, #force_flush, #shutdown] Span exporter used by the batch processor
|
|
13
|
-
|
|
12
|
+
# @param metrics_reporter [#add_to_counter, #record_value, #observe_value, nil]
|
|
13
|
+
# Resilient reporter shared with the OTLP exporter
|
|
14
|
+
def initialize(config:, exporter:, metrics_reporter:)
|
|
14
15
|
@logger = config.logger
|
|
15
16
|
@default_trace_attributes = build_default_trace_attributes(config).freeze
|
|
16
17
|
@should_export_span = config.should_export_span || Langfuse.method(:default_export_span?)
|
|
@@ -21,7 +22,7 @@ module Langfuse
|
|
|
21
22
|
max_queue_size: config.batch_size * 2,
|
|
22
23
|
schedule_delay: schedule_delay_for(config),
|
|
23
24
|
max_export_batch_size: config.batch_size,
|
|
24
|
-
metrics_reporter:
|
|
25
|
+
metrics_reporter: metrics_reporter
|
|
25
26
|
)
|
|
26
27
|
end
|
|
27
28
|
|
data/lib/langfuse/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: langfuse-rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.12.
|
|
4
|
+
version: 0.12.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SimplePractice
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09-
|
|
11
|
+
date: 2026-09-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|