Skip to content

Commit 99f26b0

Browse files
committed
fix: Log exceptions properly
1 parent 26f9a4b commit 99f26b0

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

app/jobs/application_job.rb

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,15 @@ class ApplicationJob < ActiveJob::Base
99
rescue_from(Exception) do |error|
1010
span = OpenTelemetry::Trace.current_span
1111
span.status = OpenTelemetry::Trace::Status.error(error.message)
12-
span.record_exception(error)
13-
# span.record_exception(
14-
# error,
15-
# attributes: {"job.class" => self.class.name, "job.id" => job_id}
16-
# )
12+
span.record_exception(
13+
error,
14+
attributes: {"job.class" => self.class.name, "job.id" => job_id}
15+
)
1716

18-
Rails.logger.error("Job failed",
19-
job_class: self.class.name,
20-
job_id: job_id,
21-
exception: {
22-
message: error.message,
23-
name: error.class.name,
24-
stack_trace: error.backtrace
25-
}
17+
Rails.logger.error(
18+
"Job failed",
19+
{job_class: self.class.name, job_id: job_id},
20+
error
2621
)
2722

2823
# Re-raise the exception to be handled by the job framework (SolidQueue).

config/initializers/solid_queue.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,5 @@
77
span.status = OpenTelemetry::Trace::Status.error(error.message)
88
span.record_exception(error)
99

10-
Rails.logger.error("SolidQueue thread error", exception: {
11-
message: error.message,
12-
name: error.class.name,
13-
stack_trace: error.backtrace
14-
})
10+
Rails.logger.error("SolidQueue thread error", error)
1511
end

0 commit comments

Comments
 (0)