Class: LaunchDarklyObservability::InstrumentationLogFilter
- Inherits:
-
Object
- Object
- LaunchDarklyObservability::InstrumentationLogFilter
- Defined in:
- lib/launchdarkly_observability/instrumentation_log_filter.rb
Overview
Wraps the OpenTelemetry logger to suppress the per-instrumentation install chatter ("... was successfully installed" / "... failed to install") and record the names of instrumentations that failed to install. Everything else (including level / level=) is delegated to the real logger.
OpenTelemetryConfig uses this to replace the SDK's flurry of per-instrumentation warnings with a single actionable summary.
Constant Summary collapse
- FAILED_PATTERN =
/Instrumentation: (\S+) failed to install/
Class Method Summary collapse
-
.capture_failures ⇒ Object
Run the block with OpenTelemetry.logger swapped for a filter that suppresses per-instrumentation install chatter, returning the names of any instrumentations that reported "failed to install".
-
.failure_warning(failed) ⇒ Object
Build ONE actionable warning naming the instrumentations that could not attach and how to resolve it.
Instance Method Summary collapse
- #add(severity, message = nil, progname = nil, &block) ⇒ Object
-
#initialize(delegate, failed) ⇒ InstrumentationLogFilter
constructor
A new instance of InstrumentationLogFilter.
- #method_missing(name) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(delegate, failed) ⇒ InstrumentationLogFilter
Returns a new instance of InstrumentationLogFilter.
44 45 46 47 |
# File 'lib/launchdarkly_observability/instrumentation_log_filter.rb', line 44 def initialize(delegate, failed) @delegate = delegate @failed = failed end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
62 63 64 |
# File 'lib/launchdarkly_observability/instrumentation_log_filter.rb', line 62 def method_missing(name, ...) @delegate.send(name, ...) end |
Class Method Details
.capture_failures ⇒ Object
Run the block with OpenTelemetry.logger swapped for a filter that suppresses per-instrumentation install chatter, returning the names of any instrumentations that reported "failed to install". The SDK installs instrumentations after a configure block returns, so wrap the whole OpenTelemetry::SDK.configure call — not just use_all.
19 20 21 22 23 24 25 26 27 |
# File 'lib/launchdarkly_observability/instrumentation_log_filter.rb', line 19 def self.capture_failures original = OpenTelemetry.logger failed = [] OpenTelemetry.logger = new(original, failed) yield failed ensure OpenTelemetry.logger = original end |
.failure_warning(failed) ⇒ Object
Build ONE actionable warning naming the instrumentations that could not attach and how to resolve it. Telemetry that does not depend on those instrumentations (flag-eval spans, manual instrumentation, logs, errors) keeps working regardless.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/launchdarkly_observability/instrumentation_log_filter.rb', line 33 def self.failure_warning(failed) names = failed.map { |n| n.sub('OpenTelemetry::Instrumentation::', '') }.uniq rails = defined?(::Rails) && ::Rails.respond_to?(:version) ? " on Rails #{::Rails.version}" : '' "[LaunchDarklyObservability] #{names.size} OpenTelemetry instrumentation(s) could not attach" \ "#{rails} (Ruby #{RUBY_VERSION}): #{names.join(', ')}. Those libraries will not be " \ 'auto-instrumented; flag-eval spans, manual instrumentation, logs and error capture are ' \ 'unaffected. This usually means an instrumentation gem dropped support for your framework ' \ 'version — upgrade the framework, or pin the instrumentation gem to a compatible release ' \ '(e.g. gem "opentelemetry-instrumentation-rails", "~> 0.41").' end |
Instance Method Details
#add(severity, message = nil, progname = nil, &block) ⇒ Object
58 59 60 |
# File 'lib/launchdarkly_observability/instrumentation_log_filter.rb', line 58 def add(severity, = nil, progname = nil, &block) forward?( || progname || block&.call) ? @delegate.add(severity, , progname, &block) : true end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
66 67 68 |
# File 'lib/launchdarkly_observability/instrumentation_log_filter.rb', line 66 def respond_to_missing?(name, include_private = false) @delegate.respond_to?(name, include_private) || super end |