Skip to content

Commit

Permalink
di
Browse files Browse the repository at this point in the history
  • Loading branch information
p committed Oct 25, 2024
1 parent e3db166 commit 15d1f90
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/datadog/di/remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ def receivers(telemetry)
probe = ProbeBuilder.build_from_remote_config(probe_spec)
payload = component.probe_notification_builder.build_received(probe)
component.probe_notifier_worker.add_status(payload)
# TODO delete before shipping
puts "Received probe from RC: #{probe.type} #{probe.location}"
component.logger.info("Received probe from RC: #{probe.type} #{probe.location}")

begin
# TODO test exception capture
Expand Down
20 changes: 20 additions & 0 deletions spec/datadog/di/remote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@
end

it 'calls probe manager to add a probe' do
expect(component).to receive(:logger).and_return(logger)
expect(logger).to receive(:info) do |message|
expect(message).to match(/Received probe/)
end

expect(probe_manager).to receive(:add_probe) do |probe|
expect(probe.id).to eq('11')
end
Expand All @@ -160,6 +165,11 @@

context 'probe addition raises an exception' do
it 'logs warning and consumes the exception' do
expect(component).to receive(:logger).and_return(logger)
expect(logger).to receive(:info) do |message|
expect(message).to match(/Received probe/)
end

expect(logger).to receive(:warn) do |msg|
expect(msg).to match(/Unhandled exception.*Runtime error from test/)
end
Expand All @@ -177,6 +187,11 @@
end

it 'calls probe manager to remove stale probes' do
expect(component).to receive(:logger).and_return(logger)
expect(logger).to receive(:info) do |message|
expect(message).to match(/Received probe/)
end

expect(logger).to receive(:warn) do |msg|
expect(msg).to match(/Unhandled exception.*Runtime error from test/)
end
Expand All @@ -194,6 +209,11 @@

context 'probe removal raises an exception' do
it 'logs warning and consumes the exception' do
expect(component).to receive(:logger).and_return(logger)
expect(logger).to receive(:info) do |message|
expect(message).to match(/Received probe/)
end

expect(logger).to receive(:warn) do |msg|
expect(msg).to match(/Unhandled exception.*Runtime error 1 from test/)
end
Expand Down

0 comments on commit 15d1f90

Please sign in to comment.