From 15d1f90f679f967291c1fd9a76e262068c998dcc Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 25 Oct 2024 13:43:01 -0400 Subject: [PATCH] di --- lib/datadog/di/remote.rb | 3 +-- spec/datadog/di/remote_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/datadog/di/remote.rb b/lib/datadog/di/remote.rb index d3b8e691f79..8959308bae4 100644 --- a/lib/datadog/di/remote.rb +++ b/lib/datadog/di/remote.rb @@ -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 diff --git a/spec/datadog/di/remote_spec.rb b/spec/datadog/di/remote_spec.rb index 2f39dc1f534..ecb2393e750 100644 --- a/spec/datadog/di/remote_spec.rb +++ b/spec/datadog/di/remote_spec.rb @@ -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 @@ -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 @@ -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 @@ -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