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'.freeze

Class Method Summary collapse

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

included

Class Method Details

.event_nameObject



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

def event_name
  self::EVENT_NAME
end

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



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

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



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

def span_name
  Ext::SPAN_BROADCAST
end

.span_typeObject



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

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