Sha256: 20be4d86f51878ca630d7517909bbd5cfe2a75b8afadc7fb9dc087b602146588

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

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

module OpenTelemetry
  module Instrumentation
    module ActionMailer
      DELIVER_SUBSCRIPTION = 'deliver.action_mailer'
      PROCESS_SUBSCRIPTION = 'process.action_mailer'

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

        class << self
          def subscribe_to_deliver
            ::OpenTelemetry::Instrumentation::ActiveSupport.subscribe(
              ActionMailer::Instrumentation.instance.tracer,
              DELIVER_SUBSCRIPTION,
              config[:notification_payload_transform],
              config[:disallowed_notification_payload_keys]
            )
          end

          def subscribe_to_process
            ::OpenTelemetry::Instrumentation::ActiveSupport.subscribe(
              ActionMailer::Instrumentation.instance.tracer,
              PROCESS_SUBSCRIPTION,
              config[:process_payload_transform],
              config[:disallowed_process_payload_keys]
            )
          end

          def config
            ActionMailer::Instrumentation.instance.config
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-action_mailer-0.3.0 lib/opentelemetry/instrumentation/action_mailer/railtie.rb
opentelemetry-instrumentation-action_mailer-0.2.0 lib/opentelemetry/instrumentation/action_mailer/railtie.rb