Sha256: 02753af2f1a73d0f33914d48558f790e99d63c4b4363434eb3a28fcd59150751

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

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
        option :enable_statement_attribute, default: true, 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

2 entries across 2 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-pg-0.18.1 lib/opentelemetry/instrumentation/pg/instrumentation.rb
opentelemetry-instrumentation-pg-0.18.0 lib/opentelemetry/instrumentation/pg/instrumentation.rb