Sha256: bc7ec15d983d6b42aaa1069343e366f379a8a759ef053512250de81dcbabfea6

Contents?: true

Size: 1.36 KB

Versions: 29

Compression:

Stored size: 1.36 KB

Contents

require 'ddtrace/contrib/analytics'
require 'ddtrace/contrib/action_cable/event'

module Datadog
  module Contrib
    module ActionCable
      module Events
        # Defines instrumentation for 'transmit.action_cable' event.
        #
        # A 'transmit' event sends a message to a single client subscribed to a channel.
        module Transmit
          include ActionCable::Event

          EVENT_NAME = 'transmit.action_cable'.freeze

          module_function

          def event_name
            self::EVENT_NAME
          end

          def span_name
            Ext::SPAN_TRANSMIT
          end

          def span_type
            # ActionCable transmits data over WebSockets
            Datadog::Ext::AppTypes::WEB
          end

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

            span.service = configuration[:service_name]
            span.resource = channel_class
            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_CLASS, channel_class)
            span.set_tag(Ext::TAG_TRANSMIT_VIA, payload[:via])
          end
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
ddtrace-0.51.1 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.51.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.50.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.49.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.48.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.47.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.46.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.45.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.44.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.43.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.42.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.41.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ls-trace-0.2.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.40.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.39.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.38.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.37.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.36.0 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.35.2 lib/ddtrace/contrib/action_cable/events/transmit.rb
ddtrace-0.35.1 lib/ddtrace/contrib/action_cable/events/transmit.rb