Skip to content

Commit 26f9a4b

Browse files
committed
fix: Update attributes for failed job logs and traces.
1 parent 6f7e235 commit 26f9a4b

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

app/jobs/application_job.rb

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ 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(
13-
error,
14-
attributes: {"job.class" => self.class.name, "job.id" => job_id}
15-
)
12+
span.record_exception(error)
13+
# span.record_exception(
14+
# error,
15+
# attributes: {"job.class" => self.class.name, "job.id" => job_id}
16+
# )
1617

17-
Rails.logger.error("Job failed", job_class: self.class.name, job_id: job_id,
18-
error: error.message, error_class: error.class.name,
19-
backtrace: error.backtrace&.first(5))
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+
}
26+
)
2027

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

config/initializers/solid_queue.rb

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

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

0 commit comments

Comments
 (0)