Sha256: ea59f71355bf1f1a14b18cb4be23ea8963c535ef3e363241a644c01ccdc76458

Contents?: true

Size: 1.06 KB

Versions: 7

Compression:

Stored size: 1.06 KB

Contents

module Datadog
  module Tracing
    module Contrib
      # Instrument Rails.
      module Rails
        # Rails log injection helper methods
        module LogInjection
          module_function

          def add_as_tagged_logging_logger(app)
            # we want to check if the current logger is a tagger logger instance
            # log_tags defaults to nil so we have to set as an array if nothing exists yet
            if (log_tags = app.config.log_tags).nil?
              app.config.log_tags = [proc { Tracing.log_correlation }]
            # if existing log_tags configuration exists, append to the end of the array
            elsif log_tags.is_a?(Array)
              app.config.log_tags << proc { Tracing.log_correlation }
            end
          rescue StandardError => e
            # TODO: can we use Datadog.logger at this point?
            Datadog.logger.warn(
              "Unable to add Datadog Trace context to ActiveSupport::TaggedLogging: #{e.class.name} #{e.message}"
            )
            false
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ddtrace-1.12.1 lib/datadog/tracing/contrib/rails/log_injection.rb
ddtrace-1.12.0 lib/datadog/tracing/contrib/rails/log_injection.rb
ddtrace-1.11.1 lib/datadog/tracing/contrib/rails/log_injection.rb
ddtrace-1.11.0 lib/datadog/tracing/contrib/rails/log_injection.rb
ddtrace-1.11.0.beta1 lib/datadog/tracing/contrib/rails/log_injection.rb
ddtrace-1.10.1 lib/datadog/tracing/contrib/rails/log_injection.rb
ddtrace-1.10.0 lib/datadog/tracing/contrib/rails/log_injection.rb