From 66aec5febd27a8c659d7c1037e84199ae4cdb123 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Wed, 11 Dec 2024 15:57:00 +0100 Subject: [PATCH] Fix Core::Telemetry stacktrace and error logging --- lib/datadog/core/telemetry/logging.rb | 4 ++-- spec/datadog/core/telemetry/logging_spec.rb | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/datadog/core/telemetry/logging.rb b/lib/datadog/core/telemetry/logging.rb index 7f94439fe56..0bd889bf87b 100644 --- a/lib/datadog/core/telemetry/logging.rb +++ b/lib/datadog/core/telemetry/logging.rb @@ -41,7 +41,7 @@ def self.from(exception) else 'REDACTED' end - end.join(',') + end.join("\n") end end @@ -49,7 +49,7 @@ def report(exception, level: :error, description: nil) # Annoymous exceptions to be logged as message = +'' message << (exception.class.name || exception.class.inspect) - message << ':' << description if description + message << ': ' << description if description event = Event::Log.new( message: message, diff --git a/spec/datadog/core/telemetry/logging_spec.rb b/spec/datadog/core/telemetry/logging_spec.rb index 01fdcc89b3a..35613de6638 100644 --- a/spec/datadog/core/telemetry/logging_spec.rb +++ b/spec/datadog/core/telemetry/logging_spec.rb @@ -24,7 +24,7 @@ def log!(_event) ) expect(event.payload).to include( logs: [{ message: 'RuntimeError', level: 'ERROR', - stack_trace: a_string_including(',/spec/') }] + stack_trace: a_string_including("\n/spec/") }] ) end @@ -39,12 +39,12 @@ def log!(_event) it 'sends a log event to via telemetry' do expect(component).to receive(:log!).with(instance_of(Datadog::Core::Telemetry::Event::Log)) do |event| expect(event.payload).to include( - logs: [{ message: 'RuntimeError:Must not contain PII', level: 'ERROR', + logs: [{ message: 'RuntimeError: Must not contain PII', level: 'ERROR', stack_trace: a_string_including('REDACTED') }] ) expect(event.payload).to include( - logs: [{ message: 'RuntimeError:Must not contain PII', level: 'ERROR', - stack_trace: a_string_including(',/spec/') }] + logs: [{ message: 'RuntimeError: Must not contain PII', level: 'ERROR', + stack_trace: a_string_including("\n/spec/") }] ) end @@ -66,7 +66,7 @@ def log!(_event) ) expect(event.payload).to include( logs: [{ message: /#