Module: OpenTelemetry::Instrumentation::Trilogy::Patches::Client
- Defined in:
- lib/opentelemetry/instrumentation/trilogy/patches/client.rb
Overview
Module to prepend to Trilogy for instrumentation
Instance Method Summary collapse
Instance Method Details
#initialize(options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/opentelemetry/instrumentation/trilogy/patches/client.rb', line 16 def initialize( = {}) @connection_options = # This is normally done by Trilogy#initialize @_otel_database_name = &.dig(:database) @_otel_base_attributes = _build_otel_base_attributes.freeze tracer.in_span( 'connect', attributes: client_attributes.merge!(OpenTelemetry::Instrumentation::Trilogy.attributes), kind: :client, record_exception: config[:record_exception] ) do super end end |
#ping ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/opentelemetry/instrumentation/trilogy/patches/client.rb', line 31 def ping(...) tracer.in_span( 'ping', attributes: client_attributes.merge!(OpenTelemetry::Instrumentation::Trilogy.attributes), kind: :client, record_exception: config[:record_exception] ) do super end end |
#query(sql) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/opentelemetry/instrumentation/trilogy/patches/client.rb', line 42 def query(sql) context_attributes = OpenTelemetry::Instrumentation::Trilogy.attributes tracer.in_span( OpenTelemetry::Helpers::MySQL.database_span_name( sql, context_attributes[OpenTelemetry::SemanticConventions::Trace::DB_OPERATION], @_otel_database_name, config ), attributes: client_attributes(sql).merge!(context_attributes), kind: :client, record_exception: config[:record_exception] ) do |_span, context| if propagator && sql.frozen? sql = +sql propagator.inject(sql, context: context) sql.freeze elsif propagator propagator.inject(sql, context: context) end super end end |