Sha256: dd76cc0dbb58fd48b28e329a4b5d92a980d805bc588bd085d2ce1031cbe5fea9

Contents?: true

Size: 1.01 KB

Versions: 13

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

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

          # Use `app.config.log_tags` to inject propagation tags into the default Rails logger.
          def configure_log_tags(app_config)
            # When using SemanticLogger, app_config.log_tags could be a Hash and should not be modified here
            return unless app_config.log_tags.nil? || app_config.log_tags.respond_to?(:<<)

            app_config.log_tags ||= [] # Can be nil, we initialized it if so
            app_config.log_tags << proc { Tracing.log_correlation if Datadog.configuration.tracing.log_injection }
          rescue StandardError => e
            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

13 entries across 13 versions & 1 rubygems

Version Path
datadog-2.9.0 lib/datadog/tracing/contrib/rails/log_injection.rb
datadog-2.8.0 lib/datadog/tracing/contrib/rails/log_injection.rb
datadog-2.7.1 lib/datadog/tracing/contrib/rails/log_injection.rb
datadog-2.7.0 lib/datadog/tracing/contrib/rails/log_injection.rb
datadog-2.6.0 lib/datadog/tracing/contrib/rails/log_injection.rb
datadog-2.5.0 lib/datadog/tracing/contrib/rails/log_injection.rb
datadog-2.4.0 lib/datadog/tracing/contrib/rails/log_injection.rb
datadog-2.3.0 lib/datadog/tracing/contrib/rails/log_injection.rb
datadog-2.2.0 lib/datadog/tracing/contrib/rails/log_injection.rb
datadog-2.1.0 lib/datadog/tracing/contrib/rails/log_injection.rb
datadog-2.0.0 lib/datadog/tracing/contrib/rails/log_injection.rb
datadog-2.0.0.beta2 lib/datadog/tracing/contrib/rails/log_injection.rb
datadog-2.0.0.beta1 lib/datadog/tracing/contrib/rails/log_injection.rb