Sha256: 4645bd435e5e1debd028f74c82cb30a972885bbded9bcf816cdb017316aa0232

Contents?: true

Size: 881 Bytes

Versions: 17

Compression:

Stored size: 881 Bytes

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 fixed in 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
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
plain_apm-0.10.2 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.10.0 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.9.8 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.9.7 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.9.6 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.9.5 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.9.4 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.9.3 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.9.2 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.9.1 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.9.0 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.8.8 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.8.7 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.8.6 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.8.5 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.8.4 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.8.3 lib/plain_apm/extensions/context/active_job.rb