Sha256: ce798da90ee1e6d048dd87f1e9ce978064ff05929bc30552cedcc6b71e786304

Contents?: true

Size: 1.13 KB

Versions: 4

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: :include, 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

4 entries across 4 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-pg-0.25.3 lib/opentelemetry/instrumentation/pg/instrumentation.rb
opentelemetry-instrumentation-pg-0.25.2 lib/opentelemetry/instrumentation/pg/instrumentation.rb
opentelemetry-instrumentation-pg-0.25.1 lib/opentelemetry/instrumentation/pg/instrumentation.rb
opentelemetry-instrumentation-pg-0.25.0 lib/opentelemetry/instrumentation/pg/instrumentation.rb