Module: Datadog::Tracing::Contrib::ActionCable::Events::PerformAction

Includes:
RootContextEvent
Defined in:
lib/datadog/tracing/contrib/action_cable/events/perform_action.rb

Overview

Defines instrumentation for ‘perform_action.action_cable’ event.

An action, triggered by a WebSockets client, invokes a method in the server’s channel instance.

Constant Summary collapse

EVENT_NAME =
'perform_action.action_cable'

Class Method Summary collapse

Methods included from RootContextEvent

included

Class Method Details

.event_nameObject



23
24
25
# File 'lib/datadog/tracing/contrib/action_cable/events/perform_action.rb', line 23

def event_name
  self::EVENT_NAME
end

.on_start(span, _event, _id, payload) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/datadog/tracing/contrib/action_cable/events/perform_action.rb', line 36

def on_start(span, _event, _id, payload)
  channel_class = payload[:channel_class]
  action = payload[:action]

  span.service = configuration[:service_name] if configuration[:service_name]
  span.resource = "#{channel_class}##{action}"
  span.type = span_type

  # 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)
  span.set_tag(Ext::TAG_ACTION, action)

  span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
  span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_ACTION)
end

.span_nameObject



27
28
29
# File 'lib/datadog/tracing/contrib/action_cable/events/perform_action.rb', line 27

def span_name
  Ext::SPAN_ACTION
end

.span_typeObject



31
32
33
34
# File 'lib/datadog/tracing/contrib/action_cable/events/perform_action.rb', line 31

def span_type
  # A request to perform_action comes from a WebSocket connection
  Tracing::Metadata::Ext::AppTypes::TYPE_WEB
end