Sha256: f9376a24cb5da1dea6d2daddea48b8f45f23dc5517c2c1bf0771b2ca6bf7c9e1
Contents?: true
Size: 1.57 KB
Versions: 4
Compression:
Stored size: 1.57 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 tracer.in_span( Utils.format_command(args), attributes: client_attributes.merge( 'db.statement' => Utils.format_statement(args) ), kind: :client ) do response = super(*args, &block) end response end def call_pipeline(*args, &block) response = nil tracer.in_span( 'pipeline', attributes: client_attributes.merge( 'db.statement' => Utils.format_pipeline_statement(args) ), kind: :client ) do response = super(*args, &block) end response end private def client_attributes host = options[:host] port = options[:port] { 'db.type' => '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
4 entries across 4 versions & 1 rubygems