Sha256: 5cbe680dc3cec575b5c062ac13affab019df302a6efb369b98b095f5e8616dba

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

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

module OpenTelemetry
  module Instrumentation
    module DelayedJob
      # Instrumentation class that detects and installs the DelayedJob instrumentation
      class Instrumentation < OpenTelemetry::Instrumentation::Base
        MINIMUM_VERSION = Gem::Version.new('4.1')

        install do |_config|
          require_dependencies
          register_tracer_plugin
        end

        present do
          !defined?(::Delayed).nil?
        end

        compatible do
          # Version is hardcoded in the gemspec
          # https://github.com/collectiveidea/delayed_job/blob/master/delayed_job.gemspec#L16
          gem_version = Gem.loaded_specs['delayed_job']&.version
          gem_version && gem_version >= MINIMUM_VERSION
        end

        private

        def require_dependencies
          require_relative 'plugins/tracer_plugin'
        end

        def register_tracer_plugin
          ::Delayed::Worker.plugins << Plugins::TracerPlugin
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-delayed_job-0.23.0 lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb
opentelemetry-instrumentation-delayed_job-0.22.4 lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb
opentelemetry-instrumentation-delayed_job-0.22.3 lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb
opentelemetry-instrumentation-delayed_job-0.22.2 lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb
opentelemetry-instrumentation-delayed_job-0.22.1 lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb
opentelemetry-instrumentation-delayed_job-0.22.0 lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb
opentelemetry-instrumentation-delayed_job-0.21.0 lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb
opentelemetry-instrumentation-delayed_job-0.20.1 lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb
opentelemetry-instrumentation-delayed_job-0.20.0 lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb
opentelemetry-instrumentation-delayed_job-0.19.1 lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb
opentelemetry-instrumentation-delayed_job-0.19.0 lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb
opentelemetry-instrumentation-delayed_job-0.18.5 lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb