Sha256: 63235193a996eadda4d97c70f59e480e9cadbf5b428a51af42bfac78e8bebb69
Contents?: true
Size: 1.01 KB
Versions: 11
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module PlainApm module Extensions module Context module ActiveJob # Timestamp when job was deserialized (popped off of the queue). attr_accessor :dequeued_at # TODO: would it be useful to de-serialize the whole context (e.g. user # IDs, subscriptions, etc?) 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 scheduled for Rails 7.1. super.update("trace_id" => trace_id, "enqueued_at" => Time.now.utc.iso8601(9)) end def deserialize(job) PlainApm::Extensions::Context.trace_id = job["trace_id"] self.dequeued_at = Time.now.utc.iso8601(9) super(job) end end ## # Allow tracing request ID through jobs ActiveSupport.on_load(:active_job) do |klass| klass.prepend(ActiveJob) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems