Module: OpenTelemetry::Helpers::SqlProcessor

Defined in:
lib/opentelemetry/helpers/sql_processor.rb,
lib/opentelemetry/helpers/sql_processor/version.rb,
lib/opentelemetry/helpers/sql_processor/obfuscator.rb

Overview

SQL processing utilities for OpenTelemetry instrumentation.

This module provides a unified interface for SQL processing operations commonly needed in database adapter instrumentation, including SQL obfuscation.

Defined Under Namespace

Modules: Obfuscator

Constant Summary collapse

VERSION =
'0.3.0'

Class Method Summary collapse

Class Method Details

.obfuscate_sql(sql, obfuscation_limit: 2000, adapter: :default) ⇒ String

This is a SQL obfuscation utility intended for use in database adapter instrumentation. It uses the Obfuscator module.

Parameters:

  • sql (String)

    The SQL to obfuscate.

  • obfuscation_limit (optional Integer) (defaults to: 2000)

    the length at which the SQL string will not be obfuscated

  • adapter (optional Symbol) (defaults to: :default)

    the type of database adapter calling the method. :default, :mysql, :postgres, :sqlite, :oracle, :cassandra are supported.

Returns:

  • (String)

    The SQL query string where the values are replaced with "?". When the sql statement exceeds the obfuscation limit the first matched pair from the SQL statement will be returned, with an appended truncation message. If truncation is unsuccessful, a string describing the error will be returned.



31
32
33
# File 'lib/opentelemetry/helpers/sql_processor.rb', line 31

def obfuscate_sql(sql, obfuscation_limit: 2000, adapter: :default)
  Obfuscator.obfuscate_sql(sql, obfuscation_limit: obfuscation_limit, adapter: adapter)
end