launchdarkly-observability 0.2.0 → 0.2.1
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 -0
- data/README.md +1 -1
- data/lib/launchdarkly_observability/plugin.rb +9 -0
- data/lib/launchdarkly_observability/rails.rb +64 -49
- data/lib/launchdarkly_observability/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2baa5acc1de9a83e4ca42ea6ad84dcd561e33385a65e710a7617bae21a81dbca
|
|
4
|
+
data.tar.gz: 526f1bc59cc2d878c01a23fb34218ca3125398d57dabfdc570b1324365980ab2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: daa9be90cce223d086aa59791bd6d4e42fdb84b5a82afb54de62327bf19bebb02bd004e45e2066c1058e6ede1bcfd8715368b128a1b258b2cb2601810c9d2af3
|
|
7
|
+
data.tar.gz: 86f0cd398ec94b9edb14b5aeb7efa6dd068d6f0335b38417acb386394fe4edc8b598e7e42ec667da7f8b2718a376a59797ca7f504abbe7e14dc2d3b43ef2347a
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.2.1](https://github.com/launchdarkly/observability-sdk/compare/launchdarkly-observability-ruby/0.2.0...launchdarkly-observability-ruby/0.2.1) (2026-06-02)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **ruby:** observability plugin compatibility — require server-sdk >= 8.11.0 and fix Rails Railtie load order ([#575](https://github.com/launchdarkly/observability-sdk/issues/575)) ([e9d8310](https://github.com/launchdarkly/observability-sdk/commit/e9d8310c0d0d53c20ee8a48f31279a386988d27a))
|
|
14
|
+
|
|
8
15
|
## [0.2.0](https://github.com/launchdarkly/observability-sdk/compare/launchdarkly-observability-ruby-0.1.0...launchdarkly-observability-ruby/0.2.0) (2026-03-27)
|
|
9
16
|
|
|
10
17
|
|
data/README.md
CHANGED
|
@@ -35,7 +35,7 @@ gem install launchdarkly-observability
|
|
|
35
35
|
### Dependencies
|
|
36
36
|
|
|
37
37
|
The gem includes everything needed for traces and logs out of the box:
|
|
38
|
-
- `launchdarkly-server-sdk` >= 8.0
|
|
38
|
+
- `launchdarkly-server-sdk` >= 8.11.0 (plugin support was added in 8.11.0)
|
|
39
39
|
- `opentelemetry-sdk` ~> 1.4
|
|
40
40
|
- `opentelemetry-exporter-otlp` ~> 0.28
|
|
41
41
|
- `opentelemetry-instrumentation-all` ~> 0.62
|
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
require 'launchdarkly-server-sdk'
|
|
4
4
|
|
|
5
|
+
# Plugin support (LaunchDarkly::Interfaces::Plugins) was added in launchdarkly-server-sdk 8.11.0.
|
|
6
|
+
# Surface an actionable error instead of a bare "uninitialized constant" if an older SDK is loaded.
|
|
7
|
+
unless defined?(LaunchDarkly::Interfaces::Plugins::Plugin)
|
|
8
|
+
raise LoadError, 'launchdarkly-observability requires launchdarkly-server-sdk >= 8.11.0 ' \
|
|
9
|
+
'(plugin support was added in 8.11.0). Your installed launchdarkly-server-sdk ' \
|
|
10
|
+
"version is #{defined?(LaunchDarkly::VERSION) ? LaunchDarkly::VERSION : 'unknown'}. " \
|
|
11
|
+
'Please upgrade: bundle update launchdarkly-server-sdk'
|
|
12
|
+
end
|
|
13
|
+
|
|
5
14
|
module LaunchDarklyObservability
|
|
6
15
|
# LaunchDarkly SDK Plugin that provides observability instrumentation.
|
|
7
16
|
#
|
|
@@ -4,56 +4,16 @@ require_relative 'middleware'
|
|
|
4
4
|
|
|
5
5
|
module LaunchDarklyObservability
|
|
6
6
|
if defined?(::Rails::Railtie)
|
|
7
|
-
#
|
|
7
|
+
# Controller and view helper modules are defined BEFORE the Railtie on purpose.
|
|
8
8
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
class Railtie < ::Rails::Railtie
|
|
19
|
-
initializer 'launchdarkly_observability.configure_rails' do |app|
|
|
20
|
-
app.middleware.insert_before(0, LaunchDarklyObservability::Middleware)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
config.after_initialize do
|
|
24
|
-
if defined?(ActionController::Base)
|
|
25
|
-
ActionController::Base.include(LaunchDarklyObservability::ControllerHelpers)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
if defined?(ActionController::API)
|
|
29
|
-
ActionController::API.include(LaunchDarklyObservability::ControllerHelpers)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
attach_otel_log_bridge
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
class << self
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
def attach_otel_log_bridge
|
|
39
|
-
return unless otel_logger_provider_available?
|
|
40
|
-
|
|
41
|
-
bridge = LaunchDarklyObservability::OtelLogBridge.new(OpenTelemetry.logger_provider)
|
|
42
|
-
|
|
43
|
-
if ::Rails.logger.respond_to?(:broadcast_to)
|
|
44
|
-
::Rails.logger.broadcast_to(bridge)
|
|
45
|
-
elsif defined?(ActiveSupport::Logger) && ActiveSupport::Logger.respond_to?(:broadcast)
|
|
46
|
-
::Rails.logger.extend(ActiveSupport::Logger.broadcast(bridge))
|
|
47
|
-
end
|
|
48
|
-
rescue StandardError => e
|
|
49
|
-
warn "[LaunchDarklyObservability] Could not attach log bridge to Rails.logger: #{e.message}"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def otel_logger_provider_available?
|
|
53
|
-
LaunchDarklyObservability.send(:otel_logger_provider_available?)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
9
|
+
# The Railtie's `config.after_initialize` hook references ControllerHelpers. That
|
|
10
|
+
# hook is registered via ActiveSupport's lazy load hooks, which run immediately if
|
|
11
|
+
# the :after_initialize event has already fired. When the gem is required lazily
|
|
12
|
+
# *after* Rails has booted (e.g. from an autoloaded model during a request), the
|
|
13
|
+
# block executes synchronously while this file is still loading. If the helper
|
|
14
|
+
# modules were defined further down the file, they would not exist yet and the
|
|
15
|
+
# require would raise "uninitialized constant LaunchDarklyObservability::ControllerHelpers".
|
|
16
|
+
# Defining them first makes the require order-independent.
|
|
57
17
|
|
|
58
18
|
# Controller helper methods for Rails
|
|
59
19
|
#
|
|
@@ -134,6 +94,61 @@ module LaunchDarklyObservability
|
|
|
134
94
|
end
|
|
135
95
|
end
|
|
136
96
|
|
|
97
|
+
# Rails Railtie for automatic integration
|
|
98
|
+
#
|
|
99
|
+
# This Railtie automatically:
|
|
100
|
+
# - Inserts the LaunchDarkly middleware into the Rails middleware stack
|
|
101
|
+
# - Bridges Rails.logger to the OpenTelemetry Logs pipeline (if logger provider is available)
|
|
102
|
+
# - Provides helper methods for controllers and views
|
|
103
|
+
#
|
|
104
|
+
# @example The Railtie is automatically loaded when Rails is detected
|
|
105
|
+
# # In config/initializers/launchdarkly.rb
|
|
106
|
+
# LaunchDarklyObservability.init(project_id: ENV['LD_PROJECT_ID'])
|
|
107
|
+
#
|
|
108
|
+
class Railtie < ::Rails::Railtie
|
|
109
|
+
# Private helpers are defined before `config.after_initialize` references them.
|
|
110
|
+
# The after_initialize hook can run synchronously while this class body is still
|
|
111
|
+
# evaluating (lazy require after Rails has booted — see the note above), so any
|
|
112
|
+
# method it calls must already be defined at that point.
|
|
113
|
+
class << self
|
|
114
|
+
private
|
|
115
|
+
|
|
116
|
+
def attach_otel_log_bridge
|
|
117
|
+
return unless otel_logger_provider_available?
|
|
118
|
+
|
|
119
|
+
bridge = LaunchDarklyObservability::OtelLogBridge.new(OpenTelemetry.logger_provider)
|
|
120
|
+
|
|
121
|
+
if ::Rails.logger.respond_to?(:broadcast_to)
|
|
122
|
+
::Rails.logger.broadcast_to(bridge)
|
|
123
|
+
elsif defined?(ActiveSupport::Logger) && ActiveSupport::Logger.respond_to?(:broadcast)
|
|
124
|
+
::Rails.logger.extend(ActiveSupport::Logger.broadcast(bridge))
|
|
125
|
+
end
|
|
126
|
+
rescue StandardError => e
|
|
127
|
+
warn "[LaunchDarklyObservability] Could not attach log bridge to Rails.logger: #{e.message}"
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def otel_logger_provider_available?
|
|
131
|
+
LaunchDarklyObservability.send(:otel_logger_provider_available?)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
initializer 'launchdarkly_observability.configure_rails' do |app|
|
|
136
|
+
app.middleware.insert_before(0, LaunchDarklyObservability::Middleware)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
config.after_initialize do
|
|
140
|
+
if defined?(ActionController::Base)
|
|
141
|
+
ActionController::Base.include(LaunchDarklyObservability::ControllerHelpers)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
if defined?(ActionController::API)
|
|
145
|
+
ActionController::API.include(LaunchDarklyObservability::ControllerHelpers)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
attach_otel_log_bridge
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
137
152
|
if defined?(ActionView::Base)
|
|
138
153
|
ActionView::Base.include(ViewHelpers)
|
|
139
154
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: launchdarkly-observability
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- LaunchDarkly
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-06-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: launchdarkly-server-sdk
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 8.11.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 8.11.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: opentelemetry-exporter-otlp
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|