Sha256: 6237adb2eda60137f97af4fe75c132f10991e9f7de68f29be7d65cd568515f8b

Contents?: true

Size: 1019 Bytes

Versions: 1

Compression:

Stored size: 1019 Bytes

Contents

# frozen_string_literal: true

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

module OpenTelemetry
  module Instrumentation
    module PG
      # The Instrumentation class contains logic to detect and install the Pg instrumentation
      class Instrumentation < OpenTelemetry::Instrumentation::Base
        MINIMUM_VERSION = Gem::Version.new('1.1.0')

        install do |_config|
          require_dependencies
          patch_client
        end

        present do
          defined?(::PG)
        end

        compatible do
          Gem.loaded_specs['pg'].version > Gem::Version.new(MINIMUM_VERSION)
        end

        option :peer_service, default: nil, validate: :string
        option :enable_sql_obfuscation, default: false, validate: :boolean

        private

        def require_dependencies
          require_relative 'patches/connection'
        end

        def patch_client
          ::PG::Connection.prepend(Patches::Connection)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-pg-0.17.1 lib/opentelemetry/instrumentation/pg/instrumentation.rb