Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Core::Telemetry stacktrace and error logging #4220

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading