Sha256: cd48cf63644b456cbe57279e6ae5242ef2c0a819a358c2769d4d5292e8aa9150

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 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_version > Gem::Version.new(MINIMUM_VERSION)
        end

        option :peer_service, default: nil, validate: :string
        option :db_statement, default: :obfuscate, validate: %I[omit include obfuscate]
        option :obfuscation_limit, default: 2000, validate: :integer

        private

        def gem_version
          Gem::Version.new(::PG::VERSION)
        end

        def require_dependencies
          require_relative 'patches/connection'
        end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-pg-0.29.2 lib/opentelemetry/instrumentation/pg/instrumentation.rb
opentelemetry-instrumentation-pg-0.29.1 lib/opentelemetry/instrumentation/pg/instrumentation.rb
opentelemetry-instrumentation-pg-0.29.0 lib/opentelemetry/instrumentation/pg/instrumentation.rb
opentelemetry-instrumentation-pg-0.28.0 lib/opentelemetry/instrumentation/pg/instrumentation.rb
opentelemetry-instrumentation-pg-0.27.4 lib/opentelemetry/instrumentation/pg/instrumentation.rb
opentelemetry-instrumentation-pg-0.27.2 lib/opentelemetry/instrumentation/pg/instrumentation.rb
opentelemetry-instrumentation-pg-0.27.1 lib/opentelemetry/instrumentation/pg/instrumentation.rb
opentelemetry-instrumentation-pg-0.27.0 lib/opentelemetry/instrumentation/pg/instrumentation.rb
opentelemetry-instrumentation-pg-0.26.1 lib/opentelemetry/instrumentation/pg/instrumentation.rb
opentelemetry-instrumentation-pg-0.26.0 lib/opentelemetry/instrumentation/pg/instrumentation.rb