Sha256: f434fc46f35d20734c67675a9ee1c4afe23080fea100e266e085cb09409db1c9

Contents?: true

Size: 896 Bytes

Versions: 1

Compression:

Stored size: 896 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.after_initialize do
          SUBSCRIPTIONS.each do |subscription_name|
            subscriber = OpenTelemetry::Instrumentation::ActionView::SpanSubscriber.new(
              name: subscription_name,
              tracer: ActionView::Instrumentation.instance.tracer
            )

            ::OpenTelemetry::Instrumentation::ActionView.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.3 lib/opentelemetry/instrumentation/action_view/railtie.rb