Module: PlainApm::Extensions::Context::ActiveJob
- Defined in:
- lib/plain_apm/extensions/context/active_job.rb
Instance Attribute Summary collapse
-
#dequeued_at ⇒ Object
Timestamp when job was deserialized (popped off of the queue).
Instance Method Summary collapse
- #deserialize(job) ⇒ Object
-
#serialize ⇒ Object
TODO: would it be useful to de-serialize the whole context (e.g. user IDs, subscriptions, etc?).
Instance Attribute Details
#dequeued_at ⇒ Object
Timestamp when job was deserialized (popped off of the queue).
8 9 10 |
# File 'lib/plain_apm/extensions/context/active_job.rb', line 8 def dequeued_at @dequeued_at end |
Instance Method Details
#deserialize(job) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/plain_apm/extensions/context/active_job.rb', line 19 def deserialize(job) PlainApm::Extensions::Context.trace_id = job["trace_id"] self.dequeued_at = Time.now.utc.iso8601(9) super(job) end |
#serialize ⇒ Object
TODO: would it be useful to de-serialize the whole context (e.g. user IDs, subscriptions, etc?)
12 13 14 15 16 17 |
# File 'lib/plain_apm/extensions/context/active_job.rb', line 12 def serialize trace_id = PlainApm::Extensions::Context.trace_id || SecureRandom.uuid # Rails wasn't preserving the nano-time, this has now been fixed # upstream in #39698 and fixed in Rails 7.1. super.update("trace_id" => trace_id, "enqueued_at" => Time.now.utc.iso8601(9)) end |