Module: Datadog::Contrib::Dalli::Instrumentation::InstanceMethods

Defined in:
lib/ddtrace/contrib/dalli/instrumentation.rb

Overview

InstanceMethods - implementing instrumentation

Instance Method Summary collapse

Instance Method Details

#request(op, *args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ddtrace/contrib/dalli/instrumentation.rb', line 17

def request(op, *args)
  tracer.trace(Datadog::Contrib::Dalli::Ext::SPAN_COMMAND) do |span|
    span.resource = op.to_s.upcase
    span.service = datadog_configuration[:service_name]
    span.span_type = Datadog::Contrib::Dalli::Ext::SPAN_TYPE_COMMAND

    # Set analytics sample rate
    if Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])
      Contrib::Analytics.set_sample_rate(span, datadog_configuration[:analytics_sample_rate])
    end

    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)

    super
  end
end