Module: Datadog::Tracing::Contrib::Rails::LogInjection

Defined in:
lib/datadog/tracing/contrib/rails/log_injection.rb

Overview

Rails log injection helper methods

Class Method Summary collapse

Class Method Details

.configure_log_tags(app_config) ⇒ Object

Use ‘app.config.log_tags` to inject propagation tags into the default Rails logger.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/datadog/tracing/contrib/rails/log_injection.rb', line 11

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