Sha256: 9d211206d147875370dcf87ad392d520d7ba7415ab850746b98aa261d76e3460

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

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
        render_layout.action_view
      ].freeze

      # This Railtie sets up subscriptions to relevant ActionView notifications
      class Railtie < ::Rails::Railtie
        config.after_initialize do
          ::OpenTelemetry::Instrumentation::ActiveSupport::Instrumentation.instance.install({})

          instance = ::OpenTelemetry::Instrumentation::ActionView::Instrumentation.instance
          span_name_formatter = instance.config[:legacy_span_names] ? ::OpenTelemetry::Instrumentation::ActiveSupport::LEGACY_NAME_FORMATTER : nil

          SUBSCRIPTIONS.each do |subscription_name|
            ::OpenTelemetry::Instrumentation::ActiveSupport.subscribe(
              instance.tracer,
              subscription_name,
              instance.config[:notification_payload_transform],
              instance.config[:disallowed_notification_payload_keys],
              span_name_formatter: span_name_formatter
            )
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-action_view-0.8.0 lib/opentelemetry/instrumentation/action_view/railtie.rb
opentelemetry-instrumentation-action_view-0.7.3 lib/opentelemetry/instrumentation/action_view/railtie.rb