Skip to content

Commit

Permalink
Fix Core::Telemetry stacktrace and error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Strech committed Dec 11, 2024
1 parent b6fe8c0 commit 66aec5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/datadog/core/telemetry/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ def self.from(exception)
else
'REDACTED'
end
end.join(',')
end.join("\n")
end
end

def report(exception, level: :error, description: nil)
# Annoymous exceptions to be logged as <Class:0x00007f8b1c0b3b40>
message = +''
message << (exception.class.name || exception.class.inspect)
message << ':' << description if description
message << ': ' << description if description

event = Event::Log.new(
message: message,
Expand Down
10 changes: 5 additions & 5 deletions spec/datadog/core/telemetry/logging_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -66,7 +66,7 @@ def log!(_event)
)
expect(event.payload).to include(
logs: [{ message: /#<Class:/, level: 'ERROR',
stack_trace: a_string_including(',/spec/') }]
stack_trace: a_string_including("\n/spec/") }]
)
end

Expand Down

0 comments on commit 66aec5f

Please sign in to comment.