Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions instrumentation/action_mailer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To use the instrumentation, call `use` with the name of the instrumentation:

```ruby
OpenTelemetry::SDK.configure do |c|
# Use only the ActionMailer instrumentation
# Use only the ActionMailer instrumentation
c.use 'OpenTelemetry::Instrumentation::ActionMailer'
# Use the ActionMailer instrumentation along with the rest of the Rails-related instrumentation
c.use 'OpenTelemetry::Instrumentation::Rails'
Expand All @@ -44,8 +44,8 @@ See the table below for details of what [Rails Framework Hook Events](https://gu

| Event Name | Creates Span? | Notes |
| - | - | - |
| `deliver.action_mailer` | :white_check_mark: | Creates an span with kind `internal` and email content and status|
| `process.action_mailer` | :x: | Lack of useful info so ignored |
| `deliver.action_mailer` | :white_check_mark: | Creates a span with kind `internal` and email content and status |
| `process.action_mailer` | :white_check_mark: | Creates a span with kind `internal` that will include email rendering spans |

### Options

Expand All @@ -67,9 +67,9 @@ end

## Semantic Conventions

Internal spans are named using the name of the `ActiveSupport` event that was provided (e.g. `action_mailer deliver`).
Internal spans are named using the name of the `ActiveSupport` event that was provided (e.g. `deliver.action_mailer`).

The following attributes from the notification payload for the `deliver.action_mailer` event are attached to `action_mailer deliver` spans:
The following attributes from the notification payload for the `deliver.action_mailer` event are attached:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a section describing the attributes captured by the process.action_mailer notification by default?
https://edgeguides.rubyonrails.org/active_support_instrumentation.html#process-action-mailer


| Attribute Name | Type | Notes |
| - | - | - |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
end

option :disallowed_notification_payload_keys, default: [], validate: :array
option :disallowed_process_payload_keys, default: [], validate: :array
option :notification_payload_transform, default: nil, validate: :callable
option :process_payload_transform, default: nil, validate: :callable
option :email_address, default: :omit, validate: %I[omit include]

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,29 @@
module OpenTelemetry
module Instrumentation
module ActionMailer
SUBSCRIPTIONS = %w[
deliver.action_mailer
].freeze
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({})

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

::OpenTelemetry::Instrumentation::ActiveSupport.subscribe(
ActionMailer::Instrumentation.instance.tracer,
DELIVER_SUBSCRIPTION,
config[:notification_payload_transform],
config[:disallowed_notification_payload_keys]
)

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