lib/opentelemetry/instrumentation/mysql2/patches/client.rb in opentelemetry-instrumentation-mysql2-0.10.1 vs lib/opentelemetry/instrumentation/mysql2/patches/client.rb in opentelemetry-instrumentation-mysql2-0.11.0

- old
+ new

@@ -1,8 +1,8 @@ # frozen_string_literal: true -# Copyright 2020 OpenTelemetry Authors +# Copyright The OpenTelemetry Authors # # SPDX-License-Identifier: Apache-2.0 module OpenTelemetry module Instrumentation @@ -70,20 +70,26 @@ # exposed on the mysql2 Client # https://github.com/brianmario/mysql2/blob/ca08712c6c8ea672df658bb25b931fea22555f27/lib/mysql2/client.rb#L25-L26 host = (query_options[:host] || query_options[:hostname]).to_s port = query_options[:port].to_s - { + attributes = { 'db.system' => 'mysql', 'db.instance' => database_name, 'db.url' => "mysql://#{host}:#{port}", 'net.peer.name' => host, 'net.peer.port' => port } + attributes['peer.service'] = config[:peer_service] if config[:peer_service] + attributes end def tracer Mysql2::Instrumentation.instance.tracer + end + + def config + Mysql2::Instrumentation.instance.config end def extract_statement_type(sql) QUERY_NAME_RE.match(sql) { |match| match[1].downcase } unless sql.nil? rescue StandardError => e