Sha256: 0d8fe6e7f4110b3d98b125cad6e45acb69fa10985313760a6c59871fb925879f

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

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

module OpenTelemetry
  module Instrumentation
    module Mysql2
      # The Instrumentation class contains logic to detect and install the Mysql2
      # instrumentation
      class Instrumentation < OpenTelemetry::Instrumentation::Base
        install do |config|
          if config[:enable_sql_obfuscation]
            config[:db_statement] = :obfuscate
            OpenTelemetry.logger.warn(
              'Instrumentation mysql2 configuration option enable_sql_obfuscation has been deprecated,' \
              'use db_statement option instead'
            )
          end

          require_dependencies
          patch_client
        end

        present do
          defined?(::Mysql2)
        end

        option :peer_service, default: nil, validate: :string
        option :enable_sql_obfuscation, default: false, validate: :boolean
        option :db_statement, default: :include, validate: %I[omit include obfuscate]

        private

        def require_dependencies
          require_relative 'patches/client'
        end

        def patch_client
          ::Mysql2::Client.prepend(Patches::Client)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-mysql2-0.21.1 lib/opentelemetry/instrumentation/mysql2/instrumentation.rb
opentelemetry-instrumentation-mysql2-0.21.0 lib/opentelemetry/instrumentation/mysql2/instrumentation.rb
opentelemetry-instrumentation-mysql2-0.20.1 lib/opentelemetry/instrumentation/mysql2/instrumentation.rb
opentelemetry-instrumentation-mysql2-0.20.0 lib/opentelemetry/instrumentation/mysql2/instrumentation.rb