Class: Datadog::Contrib::ActionCable::Instrumentation::ActionCableChannel::Tracer

Inherits:
Object
  • Object
show all
Defined in:
lib/ddtrace/contrib/action_cable/instrumentation.rb

Overview

Instrumentation for Channel hooks.

Class Method Summary collapse

Class Method Details

.trace(channel, hook) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ddtrace/contrib/action_cable/instrumentation.rb', line 52

def self.trace(channel, hook)
  configuration = Datadog.configuration[:action_cable]

  Datadog.tracer.trace("action_cable.#{hook}") do |span|
    span.service = configuration[:service_name]
    span.resource = "#{channel.class}##{hook}"
    span.span_type = Datadog::Ext::AppTypes::WEB

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

    # Measure service stats
    Contrib::Analytics.set_measured(span)

    span.set_tag(Ext::TAG_CHANNEL_CLASS, channel.class.to_s)

    yield
  end
end