-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add instrumentation support for action mailer #887
feat: add instrumentation support for action mailer #887
Conversation
👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the |
I'll take a closer look later this week. Apologies for waiting so long to review. |
instrumentation/action_mailer/example/app/views/test_mailer/welcome_email.html.erb
Outdated
Show resolved
Hide resolved
...rumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/instrumentation.rb
Outdated
Show resolved
Hide resolved
...rumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/instrumentation.rb
Show resolved
Hide resolved
instrumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/railtie.rb
Show resolved
Hide resolved
…lcome_email.html.erb Co-authored-by: Ariel Valentin <[email protected]>
instrumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/railtie.rb
Show resolved
Hide resolved
...rumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/instrumentation.rb
Outdated
Show resolved
Hide resolved
instrumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/railtie.rb
Show resolved
Hide resolved
…try-ruby-contrib into actionmailer-asn
...rumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/instrumentation.rb
Show resolved
Hide resolved
'email.bcc.address' => payload[:bcc], | ||
'email.origination_timestamp' => payload[:date] | ||
} | ||
new_payload.compact! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a micro optimization but checking if the values are nil
before adding them to the hash is generally faster than using compact!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for writing this, Xuan!
gem install opentelemetry-instrumentation-action_mailer | ||
gem install opentelemetry-instrumentation-rails |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intent of this code block to show you can get the ActionMailer instrumentation from the solo opentelemetry-instrumentation-action_mailer
gem or the opentelemetry-instrumentation-rails
gem?
If so, I think the opentelemetry-instrumentation-rails.gemspec
should be updated to add opentelemetry-instrumentation-action_mailer
as a dependency.
It might also be helpful to add a comment within the code block that describes the two options more clearly. It could read something like:
# Install just the ActionMailer instrumentation
gem install opentelemetry-instrumentation-action_mailer
# Install the ActionMailer instrumentation along with the rest of the Rails-related instrumentation
gem install opentelemetry-instrumentation-rails
With how it's currently written, I think I have to install both gems to get ActionMailer instrumentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might also be helpful to add a comment within the code block that describes the two options more clearly. It could read something like:
Updated
If so, I think the opentelemetry-instrumentation-rails.gemspec should be updated to add opentelemetry-instrumentation-action_mailer as a dependency.
I think it's better to have action_mailer gem released on rubygems then include rails (also for instrumentation-all)
|
||
### Options | ||
|
||
ActionMailer instrumentation doesn't expose email address by default, but if email address is needed, simply use `:email_address` option: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ActionMailer instrumentation doesn't expose email address by default, but if email address is needed, simply use `:email_address` option: | |
ActionMailer instrumentation doesn't expose email addresses by default, but if email addresses are needed, simply use `:email_address` option: |
|
||
## Active Support Instrumentation | ||
|
||
This instrumentation now relies entirely on `ActiveSupport::Notifications` and registers a custom Subscriber that listens to relevant events to report as spans. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This instrumentation now relies entirely on `ActiveSupport::Notifications` and registers a custom Subscriber that listens to relevant events to report as spans. | |
This instrumentation relies entirely on `ActiveSupport::Notifications` and registers a custom Subscriber that listens to relevant events to report as spans. |
|
||
Internal spans are named using the name of the `ActiveSupport` event that was provided (e.g. `action_mailer deliver`). | ||
|
||
Attributes that are specific to this instrumentation are recorded under `action_mailer deliver`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this saying the following attributes are on the action_mailer deliver
spans?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should incorporate "notifications payload" somewhere into this sentence to make it clear that's where the attributes are coming from.
Maybe:
Attributes that are specific to this instrumentation are recorded under `action_mailer deliver`: | |
The following attributes from the notification payload for the `deliver.action_mailer` event are attached to `action_mailer deliver` spans: |
...rumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/instrumentation.rb
Show resolved
Hide resolved
...rumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/instrumentation.rb
Outdated
Show resolved
Hide resolved
...rumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/instrumentation.rb
Outdated
Show resolved
Hide resolved
...ation/action_mailer/test/opentelemetry/instrumentation/action_mailer/instrumentation_test.rb
Show resolved
Hide resolved
...rumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/instrumentation.rb
Show resolved
Hide resolved
Co-authored-by: Kayla Reopelle (she/her) <[email protected]>
Co-authored-by: Kayla Reopelle (she/her) <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved as-is, but I have a few documentation-related suggestions you're welcome to apply or ignore.
Thanks, Xuan!
instrumentation/action_mailer/example/trace_request_demonstration.ru
Outdated
Show resolved
Hide resolved
...rumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/instrumentation.rb
Show resolved
Hide resolved
...rumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/instrumentation.rb
Show resolved
Hide resolved
One other thing (not sure I said this already or just thought it) -- could you either add this gem to the rails instrumentation gemspec as part of this PR or open an issue about this? Currently the README is inaccurate. The ActionMailer instrumentation isn't a dependency of the Rails project, so it won't be installed when We've already done a lot in this PR, so I don't mind adding this on as a follow-up, but didn't want to assume your preference. |
…ion.ru Co-authored-by: Kayla Reopelle (she/her) <[email protected]>
Co-authored-by: Kayla Reopelle (she/her) <[email protected]>
Yes, I created an issue that is tagged on this PR |
| 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 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whether to open a new issue, but wanted to try here first.
We had added instrumentation for ActionMailer
ourselves using OpenTelemetry::Instrumentation::ActiveSupport.subscribe
, but had added process.action_mailer
as well. The span itself doesn't have interesting attributes but it helps wrap everything necessary to render the email in a common span. We find this very useful. For example:
Helps see how long it takes to render the email vs actually deliver it:
Would you be open to adding this as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally add functionality based on our user need and in many cases we tend to add features that we (maintainers) regularly use in production.
We are happy to review any contributions you'd like to submit to the community and look forward to your help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful! I'll look into it!
Description
Adding support for instrumenting action mailer using active support notification. This instrumentation is modified based on action_view.
Related: #293
Test
Sample span_data