Sha256: b04834ed0e1eba1fa7dee56347b82f74b08836945909d1f8bb13581fa7dc7910

Contents?: true

Size: 1002 Bytes

Versions: 1

Compression:

Stored size: 1002 Bytes

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  module Instrumentation
    module ActionView
      SUBSCRIPTIONS = %w[
        render_template.action_view
        render_partial.action_view
        render_collection.action_view
      ].freeze

      # This Railtie sets up subscriptions to relevant ActionView notifications
      class Railtie < ::Rails::Railtie
        config.before_initialize do
          ::ActiveSupport::Notifications.notifier = Fanout.new
        end

        config.after_initialize do
          SUBSCRIPTIONS.each do |subscription_name|
            subscriber = OpenTelemetry::Instrumentation::ActionView::SpanSubscriber.new(
              name: subscription_name,
              tracer: ActionView::Instrumentation.instance.tracer
            )
            ::ActiveSupport::Notifications.notifier.subscribe(subscription_name, subscriber)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-action_view-0.1.0 lib/opentelemetry/instrumentation/action_view/railtie.rb