Module: Datadog::Tracing::Contrib::ActionCable::Events::Broadcast

Includes:
Datadog::Tracing::Contrib::ActionCable::Event
Defined in:
lib/datadog/tracing/contrib/action_cable/events/broadcast.rb

Overview

Defines instrumentation for ‘broadcast.action_cable’ event.

A single ‘broadcast’ event will trigger as many ‘transmit’ events as there are clients subscribed to a channel.

Constant Summary collapse

EVENT_NAME =
'broadcast.action_cable'

Class Method Summary collapse

Methods included from Datadog::Tracing::Contrib::ActionCable::Event

included

Class Method Details

.event_nameObject



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

def event_name
  self::EVENT_NAME
end

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



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/datadog/tracing/contrib/action_cable/events/broadcast.rb', line 37

def on_start(span, _event, _id, payload)
  channel = payload[:broadcasting] # Channel has high cardinality
  span.service = configuration[:service_name] if configuration[:service_name]
  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

  span.set_tag(Ext::TAG_CHANNEL, channel)
  span.set_tag(Ext::TAG_BROADCAST_CODER, payload[:coder])

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

.span_nameObject



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

def span_name
  Ext::SPAN_BROADCAST
end

.span_typeObject



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

def span_type
  # Starts a broadcast of messages over WebSockets
  Tracing::Metadata::Ext::AppTypes::TYPE_WEB
end