Class: Logtail::Integrator
- Inherits:
-
Object
- Object
- Logtail::Integrator
- Defined in:
- lib/logtail/integrator.rb
Overview
Base class for ‘Logtail::Integrations::*`. Provides a common interface for all integrators. An integrator is a single specific integration into a part of a library. See Integration for higher library level integration settings.
Defined Under Namespace
Classes: RequirementNotMetError
Class Attribute Summary collapse
-
.enabled ⇒ Object
writeonly
Sets the attribute enabled.
Class Method Summary collapse
-
.enabled? ⇒ Boolean
Allows you to enable / disable specific integrations.
-
.integrate!(*args) ⇒ Object
Convenience class level method that runs the integrator by instantiating a new object and calling #integrate!.
Instance Method Summary collapse
-
#integrate! ⇒ Object
Abstract method that each integration must implement.
Class Attribute Details
.enabled=(value) ⇒ Object (writeonly)
Sets the attribute enabled
12 13 14 |
# File 'lib/logtail/integrator.rb', line 12 def enabled=(value) @enabled = value end |
Class Method Details
.enabled? ⇒ Boolean
Disabling specific low level integrations should only be needed for edge cases. If you want to disable integration with an entire library, we recommend doing so at a higher level. Ex: ‘Logtail::Integrations::ActiveRecord.enabled = false`.
Allows you to enable / disable specific integrations.
22 23 24 |
# File 'lib/logtail/integrator.rb', line 22 def enabled? @enabled != false end |
.integrate!(*args) ⇒ Object
Convenience class level method that runs the integrator by instantiating a new object and calling #integrate!. It also takes care to look at the if the integrator is enabled, skipping it if not.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/logtail/integrator.rb', line 29 def integrate!(*args) if !enabled? Config.instance.debug_logger.debug("#{name} integration disabled, skipping") if Config.instance.debug_logger return false end new(*args).integrate! Config.instance.debug_logger.debug("Integrated #{name}") if Config.instance.debug_logger true # RequirementUnsatisfiedError is the only silent failure we support rescue RequirementNotMetError => e Config.instance.debug_logger.debug("Failed integrating #{name}: #{e.}") if Config.instance.debug_logger false end |
Instance Method Details
#integrate! ⇒ Object
Abstract method that each integration must implement.
46 47 48 |
# File 'lib/logtail/integrator.rb', line 46 def integrate! raise NotImplementedError.new end |