Sha256: 80491303bb9d9ab9cd1acc8fc581e91fbc00d65f9997d8fef4746c9a435cd5be

Contents?: true

Size: 1.56 KB

Versions: 12

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

require_relative '../patcher'
require_relative 'instrumentation'

module Datadog
  module Tracing
    module Contrib
      # Datadog Lograge integration.
      module Lograge
        # Patcher enables patching of 'lograge' module.
        module Patcher
          include Contrib::Patcher

          module_function

          def target_version
            Integration.version
          end

          # patch applies our patch
          def patch
            # ActiveSupport::TaggedLogging is the default Rails logger since Rails 5
            if defined?(::ActiveSupport::TaggedLogging::Formatter) &&
                ::Lograge::LogSubscribers::ActionController
                    .logger&.formatter.is_a?(::ActiveSupport::TaggedLogging::Formatter)
              Datadog.logger.warn(
                'Lograge and ActiveSupport::TaggedLogging (the default Rails log formatter) are not compatible: ' \
                  'Lograge does not account for Rails log tags, creating polluted logs and breaking log formatting. ' \
                  'Traces and Logs correlation may not work. ' \
                  'Either: 1. Disable tagged logging in your Rails configuration ' \
                  '`config.logger = ActiveSupport::Logger.new(STDOUT); ' \
                  'config.active_job.logger = ActiveSupport::Logger.new(STDOUT)` ' \
                  'or 2. Use the `semantic_logger` gem instead of `lograge`.'
              )
            end

            ::Lograge::LogSubscribers::Base.include(Instrumentation)
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
datadog-2.12.2 lib/datadog/tracing/contrib/lograge/patcher.rb
datadog-2.12.1 lib/datadog/tracing/contrib/lograge/patcher.rb
datadog-2.12.0 lib/datadog/tracing/contrib/lograge/patcher.rb
datadog-2.11.0 lib/datadog/tracing/contrib/lograge/patcher.rb
datadog-2.10.0 lib/datadog/tracing/contrib/lograge/patcher.rb
datadog-2.9.0 lib/datadog/tracing/contrib/lograge/patcher.rb
datadog-2.8.0 lib/datadog/tracing/contrib/lograge/patcher.rb
datadog-2.7.1 lib/datadog/tracing/contrib/lograge/patcher.rb
datadog-2.7.0 lib/datadog/tracing/contrib/lograge/patcher.rb
datadog-2.6.0 lib/datadog/tracing/contrib/lograge/patcher.rb
datadog-2.5.0 lib/datadog/tracing/contrib/lograge/patcher.rb
datadog-2.4.0 lib/datadog/tracing/contrib/lograge/patcher.rb