Sha256: a5f8077f6ca18a8750a30094ab4daf6fff2337e51c50133f24669d7b4f4474d5

Contents?: true

Size: 1.43 KB

Versions: 26

Compression:

Stored size: 1.43 KB

Contents

# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

require 'new_relic/agent/instrumentation/notifications_subscriber'

module NewRelic
  module Agent
    module Instrumentation
      class ActionCableSubscriber < NotificationsSubscriber
        PERFORM_ACTION = 'perform_action.action_cable'.freeze

        def start_segment(name, id, payload) # THREAD_LOCAL_ACCESS
          finishable = if name == PERFORM_ACTION
            Tracer.start_transaction_or_segment(
              name: transaction_name_from_payload(payload),
              category: :action_cable
            )
          else
            Tracer.start_segment(name: metric_name_from_payload(name, payload))
          end
          push_segment(id, finishable)
        end

        private

        def transaction_name_from_payload(payload)
          "Controller/ActionCable/#{payload[:channel_class]}/#{payload[:action]}"
        end

        def metric_name_from_payload(name, payload)
          "Ruby/ActionCable/#{metric_name(payload)}/#{action_name(name)}"
        end

        def metric_name(payload)
          payload[:broadcasting] || payload[:channel_class]
        end

        DOT_ACTION_CABLE = '.action_cable'.freeze

        def action_name(name)
          name.gsub(DOT_ACTION_CABLE, NewRelic::EMPTY_STR)
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
newrelic_rpm-9.16.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.15.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.14.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.13.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.12.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.11.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.10.2 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.10.1 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.10.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.9.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.8.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.7.1 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.7.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.6.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.5.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.4.2 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.4.1 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.4.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.3.1 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb
newrelic_rpm-9.3.0 lib/new_relic/agent/instrumentation/action_cable_subscriber.rb