Skip to content

Commit b9a069b

Browse files
authored
Merge pull request #1774 from sanger/Y26-015-emq-logging-visibility
Y26-015 - EMQ Logging visibility
2 parents 2569c23 + 1730068 commit b9a069b

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

app/messages/emq/publishing_job.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ def publish(objects, message_config, schema_key) # rubocop:disable Metrics/AbcSi
4444
if message_builder_config_obj.nil?
4545
Rails.logger.error('Message builder configuration not found for ' \
4646
"schema key: #{schema_key} and version: #{version}")
47+
# Ensure we also notify via email as this could indicate a systemic issue
48+
# and it is important we are made aware of it as it could affect volume tracking data
49+
ExceptionNotifier.notify_exception(
50+
StandardError.new(
51+
"Message builder config not found for schema key: #{schema_key} and version: #{version}"
52+
)
53+
)
4754
return
4855
end
4956
message_builder_class = message_builder_config_obj.message_class.to_s.constantize
@@ -75,6 +82,9 @@ def publish(objects, message_config, schema_key) # rubocop:disable Metrics/AbcSi
7582
# This is to prevent the job from failing and to allow the job to continue
7683
# These logs can be monitored through Kibana
7784
Rails.logger.error("Failed to publish message to EMQ: #{e.message}")
85+
# Ensure we also notify via email as this could indicate a systemic issue
86+
# and it is important we are made aware of it as it could affect volume tracking data
87+
ExceptionNotifier.notify_exception(e)
7888
end
7989
end
8090

spec/messages/emq/publishing_job_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,14 @@
9090
bunny_config[:amqp][:schemas][:subjects][:volume_tracking][:version] = 3
9191
expect(emq_sender_mock).not_to receive(:send_message)
9292
expect(Rails.logger).to receive(:error).with('Message builder configuration not found for schema key: volume_tracking and version: 3')
93+
expect(ExceptionNotifier).to receive(:notify_exception).with(StandardError.new('Message builder config not found for schema key: volume_tracking and version: 3'))
9394
publishing_job.publish(aliquot, Pipelines.pacbio, 'volume_tracking')
9495
end
9596

9697
it 'logs error message when the EMQ is down' do
9798
allow(emq_sender_mock).to receive(:send_message).and_raise(StandardError)
9899
expect(Rails.logger).to receive(:error).with('Failed to publish message to EMQ: StandardError')
100+
expect(ExceptionNotifier).to receive(:notify_exception).with(instance_of(StandardError))
99101
publishing_job.publish(aliquot, Pipelines.pacbio, 'volume_tracking')
100102
end
101103
end

0 commit comments

Comments
 (0)