Sha256: a15c63356b548a73165fa3b24f90cfa63b585af0899c22921a6c456512342b18

Contents?: true

Size: 894 Bytes

Versions: 4

Compression:

Stored size: 894 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
          ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)

          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

4 entries across 4 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-active_job-0.1.5 lib/opentelemetry/instrumentation/active_job/patches/base.rb
opentelemetry-instrumentation-active_job-0.1.4 lib/opentelemetry/instrumentation/active_job/patches/base.rb
opentelemetry-instrumentation-active_job-0.1.3 lib/opentelemetry/instrumentation/active_job/patches/base.rb
opentelemetry-instrumentation-active_job-0.1.2 lib/opentelemetry/instrumentation/active_job/patches/base.rb