Sha256: 4c92fd4523a34a96a7ef36989f5c62f343d7e058c66e4df62c54c29324ac5ab2

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

require 'ddtrace/ext/net'
require 'ddtrace/contrib/dalli/quantize'

module Datadog
  module Contrib
    module Dalli
      # Instruments every interaction with the memcached server
      module Instrumentation
        module_function

        def patch!
          ::Dalli::Server.class_eval do
            alias_method :__request, :request

            def request(op, *args)
              pin = Datadog::Pin.get_from(::Dalli)

              pin.tracer.trace(Datadog::Contrib::Dalli::Ext::SPAN_COMMAND) do |span|
                span.resource = op.to_s.upcase
                span.service = pin.service
                span.span_type = pin.app_type
                span.set_tag(Datadog::Ext::NET::TARGET_HOST, hostname)
                span.set_tag(Datadog::Ext::NET::TARGET_PORT, port)
                cmd = Datadog::Contrib::Dalli::Quantize.format_command(op, args)
                span.set_tag(Datadog::Contrib::Dalli::Ext::TAG_COMMAND, cmd)

                __request(op, *args)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ddtrace-0.19.1 lib/ddtrace/contrib/dalli/instrumentation.rb
ddtrace-0.19.0 lib/ddtrace/contrib/dalli/instrumentation.rb
ddtrace-0.18.3 lib/ddtrace/contrib/dalli/instrumentation.rb
ddtrace-0.18.2 lib/ddtrace/contrib/dalli/instrumentation.rb
ddtrace-0.18.1 lib/ddtrace/contrib/dalli/instrumentation.rb
ddtrace-0.18.0 lib/ddtrace/contrib/dalli/instrumentation.rb
ddtrace-0.17.3 lib/ddtrace/contrib/dalli/instrumentation.rb
ddtrace-0.17.2 lib/ddtrace/contrib/dalli/instrumentation.rb
ddtrace-0.17.1 lib/ddtrace/contrib/dalli/instrumentation.rb
ddtrace-0.17.0 lib/ddtrace/contrib/dalli/instrumentation.rb