Module: Datadog::Tracing::Contrib::SemanticLogger::Instrumentation::InstanceMethods

Defined in:
lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb

Overview

Instance methods for configuration

Instance Method Summary collapse

Instance Method Details

#log(log, message = nil, progname = nil, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb', line 15

def log(log, message = nil, progname = nil, &block)
  return super unless Datadog.configuration.tracing.log_injection
  return super unless Datadog.configuration.tracing[:semantic_logger].enabled
  return super unless log.is_a?(::SemanticLogger::Log)

  original_named_tags = log.named_tags || {}

  # Retrieves trace information for current thread
  correlation = Tracing.correlation

  # if the user already has conflicting log_tags
  # we want them to clobber ours, because we should allow them to override if needed.
  log.named_tags = correlation.to_h.merge(original_named_tags)
  super(log, message, progname, &block)
end