Sha256: 443843dec00c5a3618e8f0f1dc6f8068fbef5f44e71883b108918f9d8bcd7eba

Contents?: true

Size: 818 Bytes

Versions: 2

Compression:

Stored size: 818 Bytes

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  module Instrumentation
    module ActiveJob
      module Patches
        # Module to prepend to ActiveJob::Core for context propagation.
        module Base
          def self.prepended(base)
            base.class_eval do
              attr_accessor :metadata
            end
          end

          def initialize(*args)
            @metadata = {}
            super
          end

          def serialize
            super.merge('metadata' => serialize_arguments(metadata))
          end

          def deserialize(job_data)
            self.metadata = (deserialize_arguments(job_data['metadata']) || []).to_h
            super
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-active_job-0.1.1 lib/opentelemetry/instrumentation/active_job/patches/base.rb
opentelemetry-instrumentation-active_job-0.1.0 lib/opentelemetry/instrumentation/active_job/patches/base.rb