Sha256: d875e9a5de165903e2ba7d39d5eece41c03d48670da6363f2f78fd27800f7c70
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
# frozen_string_literal: true # Copyright 2020 OpenTelemetry Authors # # SPDX-License-Identifier: Apache-2.0 module OpenTelemetry module Instrumentation module Redis module Patches # Module to prepend to Redis::Client for instrumentation module Client def call(*args, &block) response = nil attributes = client_attributes attributes['db.statement'] = Utils.format_statement(args) tracer.in_span( Utils.format_command(args), attributes: attributes, kind: :client ) do response = super(*args, &block) end response end def call_pipeline(*args, &block) response = nil attributes = client_attributes attributes['db.statement'] = Utils.format_pipeline_statement(args) tracer.in_span( 'pipeline', attributes: attributes, kind: :client ) do response = super(*args, &block) end response end private def client_attributes host = options[:host] port = options[:port] OpenTelemetry::Instrumentation::Redis.attributes.merge( 'db.system' => 'redis', 'db.instance' => options[:db].to_s, 'db.url' => "redis://#{host}:#{port}", 'net.peer.name' => host, 'net.peer.port' => port ) end def tracer Redis::Instrumentation.instance.tracer end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opentelemetry-instrumentation-redis-0.10.1 | lib/opentelemetry/instrumentation/redis/patches/client.rb |