Sha256: 5cdb39c6427831e646f7715067263b8dd87d42cf652833ab1fabc1b4ee1bad73

Contents?: true

Size: 1.38 KB

Versions: 12

Compression:

Stored size: 1.38 KB

Contents

# typed: true

require_relative '../../../core/logging/ext'

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

          # Instance methods for configuration
          module InstanceMethods
            def custom_options(event)
              return super unless Datadog.configuration.tracing[:lograge].enabled

              original_custom_options = super(event)

              # Retrieves trace information for current thread
              correlation = Tracing.correlation
              # merge original lambda with datadog context

              datadog_trace_log_hash = {
                # Adds IDs as tags to log output
                dd: {
                  # To preserve precision during JSON serialization, use strings for large numbers
                  trace_id: correlation.trace_id.to_s,
                  span_id: correlation.span_id.to_s,
                  env: correlation.env.to_s,
                  service: correlation.service.to_s,
                  version: correlation.version.to_s
                },
                ddsource: Core::Logging::Ext::DD_SOURCE
              }

              datadog_trace_log_hash.merge(original_custom_options)
            end
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ddtrace-1.9.0 lib/datadog/tracing/contrib/lograge/instrumentation.rb
ddtrace-1.8.0 lib/datadog/tracing/contrib/lograge/instrumentation.rb
ddtrace-1.7.0 lib/datadog/tracing/contrib/lograge/instrumentation.rb
ddtrace-1.6.1 lib/datadog/tracing/contrib/lograge/instrumentation.rb
ddtrace-1.6.0 lib/datadog/tracing/contrib/lograge/instrumentation.rb
ddtrace-1.5.2 lib/datadog/tracing/contrib/lograge/instrumentation.rb
ddtrace-1.5.1 lib/datadog/tracing/contrib/lograge/instrumentation.rb
ddtrace-1.5.0 lib/datadog/tracing/contrib/lograge/instrumentation.rb
ddtrace-1.4.2 lib/datadog/tracing/contrib/lograge/instrumentation.rb
ddtrace-1.4.1 lib/datadog/tracing/contrib/lograge/instrumentation.rb
ddtrace-1.4.0 lib/datadog/tracing/contrib/lograge/instrumentation.rb
ddtrace-1.3.0 lib/datadog/tracing/contrib/lograge/instrumentation.rb