Module: OpenTelemetry::Instrumentation::PG::Patches::ConnectionHelper
- Defined in:
- lib/opentelemetry/instrumentation/pg/patches/connection.rb
Overview
Utility methods for setting connection attributes from Connect module
Class Method Summary collapse
Class Method Details
.set_connection_attributes(span, conn, config) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/opentelemetry/instrumentation/pg/patches/connection.rb', line 19 def set_connection_attributes(span, conn, config) attributes = { 'db.system' => 'postgresql', 'db.name' => conn.db, 'db.user' => conn.user } attributes['peer.service'] = config[:peer_service] if config[:peer_service] h = conn.host if h&.start_with?('/') attributes['net.sock.family'] = 'unix' attributes['net.peer.name'] = h else attributes['net.transport'] = 'ip_tcp' attributes['net.peer.name'] = h attributes['net.peer.port'] = conn.port if defined?(::PG::DEF_PGPORT) end attributes.merge!(OpenTelemetry::Instrumentation::PG.attributes) attributes.compact! span.add_attributes(attributes) end |