Skip to content

Commit

Permalink
ci: Add ActionMailer CI (open-telemetry#976)
Browse files Browse the repository at this point in the history
* ci: Add ActionMailer CI

* ci: Linter fixes

* squash: drop pry-byebug
  • Loading branch information
arielvalentin authored May 13, 2024
1 parent 02df9ba commit 6762619
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-instrumentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
fail-fast: false
matrix:
gem:
- action_mailer
- action_pack
- action_view
- active_job
Expand Down
1 change: 0 additions & 1 deletion instrumentation/action_mailer/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ gemspec
group :test do
gem 'opentelemetry-instrumentation-base', path: '../base'
gem 'opentelemetry-instrumentation-active_support', path: '../active_support'
gem 'pry-byebug'
end
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module ActionMailer
# The Instrumentation class contains logic to detect and install the ActionMailer instrumentation
class Instrumentation < OpenTelemetry::Instrumentation::Base
MINIMUM_VERSION = Gem::Version.new('6.1.0')
EMAIL_ATTRIBUTE = ['email.to.address', 'email.from.address', 'email.cc.address', 'email.bcc.address']
EMAIL_ATTRIBUTE = %w[email.to.address email.from.address email.cc.address email.bcc.address].freeze

install do |_config|
resolve_email_address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'minitest', '~> 5.0'
spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1'
spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3'
spec.add_development_dependency 'rails', '>= 6.1'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rubocop', '~> 1.60.1'
spec.add_development_dependency 'rubocop-performance', '~> 1.20'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
let(:instrumentation) { OpenTelemetry::Instrumentation::ActionMailer::Instrumentation.instance }
let(:payload) do
{
:mailer => "TestMailer",
:message_id => "[email protected]",
:subject => "Welcome to OpenTelemetry!",
:to => ["[email protected]"],
:from => ["[email protected]"],
:bcc => ["[email protected]"],
:cc => ["[email protected]"],
:perform_deliveries => true
mailer: 'TestMailer',
message_id: '[email protected]',
subject: 'Welcome to OpenTelemetry!',
to: ['[email protected]'],
from: ['[email protected]'],
bcc: ['[email protected]'],
cc: ['[email protected]'],
perform_deliveries: true
}
end

Expand Down Expand Up @@ -62,14 +62,14 @@
describe '#transform_payload' do
it 'with simple payload' do
payload = {
:mailer => "TestMailer",
:message_id => "[email protected]",
:subject => "Welcome to OpenTelemetry!",
:to => ["[email protected]"],
:from => ["[email protected]"],
:bcc => ["[email protected]"],
:cc => ["[email protected]"],
:perform_deliveries => true
mailer: 'TestMailer',
message_id: '[email protected]',
subject: 'Welcome to OpenTelemetry!',
to: ['[email protected]'],
from: ['[email protected]'],
bcc: ['[email protected]'],
cc: ['[email protected]'],
perform_deliveries: true
}
tranformed_payload = instrumentation.send(:transform_payload, payload)

Expand All @@ -85,15 +85,14 @@

describe '#ecs_mail_convention' do
it 'with user-defined payload' do

original_config = instrumentation.instance_variable_get(:@config)
modified_config = original_config.dup

modified_config[:notification_payload_transform] = lambda { |payload| payload['email.message_id'] = 'fake_message_id' }
modified_config[:notification_payload_transform] = ->(payload) { payload['email.message_id'] = 'fake_message_id' }
instrumentation.instance_variable_set(:@config, modified_config)

instrumentation.send(:ecs_mail_convention)
payload = { :mailer => "TestMailer"}
payload = { mailer: 'TestMailer' }

tranformed_payload = instrumentation.config[:notification_payload_transform].call(payload)

Expand All @@ -103,7 +102,6 @@
end

it 'without user-defined payload' do

tranformed_payload = instrumentation.config[:notification_payload_transform].call(payload)

_(tranformed_payload['email.message_id']).must_equal '[email protected]'
Expand Down

0 comments on commit 6762619

Please sign in to comment.