Sha256: d8ab51b06d776e0d60fbca0580ee0e5f26d9693a87bf9b4e53f45eaf38a03481

Contents?: true

Size: 1.16 KB

Versions: 25

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module Datadog
  module Tracing
    module Contrib
      module SemanticLogger
        # Instrumentation for SemanticLogger
        module Instrumentation
          def self.included(base)
            base.prepend(InstanceMethods)
          end

          # Instance methods for configuration
          module InstanceMethods
            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
          end
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
datadog-2.7.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
datadog-2.6.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
datadog-2.5.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
datadog-2.4.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
datadog-2.3.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
datadog-2.2.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
ddtrace-1.23.3 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
ddtrace-1.23.2 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
datadog-2.1.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
datadog-2.0.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
ddtrace-1.23.1 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
datadog-2.0.0.beta2 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
ddtrace-1.22.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
datadog-2.0.0.beta1 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
ddtrace-1.21.1 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
ddtrace-1.21.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
ddtrace-1.20.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
ddtrace-1.19.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
ddtrace-1.18.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb
ddtrace-1.17.0 lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb