class Logtail::Integrator

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.

Attributes

enabled[W]

Public Class Methods

enabled?() click to toggle source

Allows you to enable / disable specific integrations.

@note 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`.

@example

Logtail::Integrations::ActiveRecord::LogSubscriber.enabled = false
# File lib/logtail/integrator.rb, line 22
def enabled?
  @enabled != false
end
integrate!(*args) click to toggle source

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.

# 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.message}") if Config.instance.debug_logger
  false
end

Public Instance Methods

integrate!() click to toggle source

Abstract method that each integration must implement.

# File lib/logtail/integrator.rb, line 46
def integrate!
  raise NotImplementedError.new
end