DEV: Log sidekiq job opts as string instead of hash (#28012)
This ensures that elasticsearch doesn't parse it as an object. There are too many combination of job opts so we don't want elasticsearch to be parsing and indexing this field as an object.
This commit is contained in:
parent
6fb91b85ba
commit
2d59795e28
|
@ -99,7 +99,7 @@ class DiscourseLogstashLogger < Logger
|
|||
|
||||
if progname == "sidekiq-exception"
|
||||
event["job.class"] = opts.dig(:context, :job)
|
||||
event["job.opts"] = opts.dig(:context, :opts)
|
||||
event["job.opts"] = opts.dig(:context, :opts)&.stringify_keys&.to_s
|
||||
event["job.problem_db"] = opts.dig(:context, :problem_db)
|
||||
event["exception.class"] = opts[:exception_class]
|
||||
event["exception.message"] = opts[:exception_message]
|
||||
|
|
|
@ -74,7 +74,7 @@ RSpec.describe DiscourseLogstashLogger do
|
|||
expect(parsed["exception.class"]).to eq("Some::StandardError")
|
||||
expect(parsed["exception.message"]).to eq("some job error message")
|
||||
expect(parsed["job.class"]).to eq("SomeJob")
|
||||
expect(parsed["job.opts"]).to eq({ "user_id" => 1 })
|
||||
expect(parsed["job.opts"]).to eq("{\"user_id\"=>1}")
|
||||
expect(parsed["job.problem_db"]).to eq("some_db")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue