Sha256: bb502ef74489c18e269392e591e590b203531a66baade202e2e3d6da68e9a91a

Contents?: true

Size: 697 Bytes

Versions: 10

Compression:

Stored size: 697 Bytes

Contents

# frozen_string_literal: true

module PlainApm
  module Extensions
    module Context
      module ActiveJob
        # 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
          super.update("trace_id" => trace_id)
        end

        def deserialize(job)
          PlainApm::Extensions::Context.trace_id = job["trace_id"]

          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

10 entries across 10 versions & 1 rubygems

Version Path
plain_apm-0.5.5 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.5.4 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.5.3 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.5.2 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.5.1 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.5.0 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.4.0 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.3.0 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.2.9 lib/plain_apm/extensions/context/active_job.rb
plain_apm-0.2.8 lib/plain_apm/extensions/context/active_job.rb