Sha256: 1455a99d208434563a6c3f9010bbe3565c23ad886b33577dd98164dc613a03a3

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

module Datadog
  module Contrib
    module ActionCable
      module Instrumentation
        # When a new WebSocket is open, we receive a Rack request resource name "GET -1".
        # This module overrides the current Rack resource name to provide a meaningful name.
        module ActionCableConnection
          def on_open
            Datadog.tracer.trace(Ext::SPAN_ON_OPEN) do |span|
              begin
                span.resource = "#{self.class}#on_open"
                span.span_type = Datadog::Ext::AppTypes::WEB

                span.set_tag(Ext::TAG_ACTION, 'on_open')
                span.set_tag(Ext::TAG_CONNECTION, self.class.to_s)

                # Set the resource name of the Rack request span
                rack_request_span = env[Datadog::Contrib::Rack::TraceMiddleware::RACK_REQUEST_SPAN]
                rack_request_span.resource = span.resource if rack_request_span
              rescue StandardError => e
                Datadog::Logger.log.error("Error preparing span for ActionCable::Connection: #{e}")
              end

              super
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ddtrace-0.34.2 lib/ddtrace/contrib/action_cable/instrumentation.rb
ddtrace-0.34.1 lib/ddtrace/contrib/action_cable/instrumentation.rb
ddtrace-0.34.0 lib/ddtrace/contrib/action_cable/instrumentation.rb
ddtrace-0.33.1 lib/ddtrace/contrib/action_cable/instrumentation.rb
ddtrace-0.33.0 lib/ddtrace/contrib/action_cable/instrumentation.rb
ddtrace-0.32.0 lib/ddtrace/contrib/action_cable/instrumentation.rb
ddtrace-0.31.1 lib/ddtrace/contrib/action_cable/instrumentation.rb