Sha256: 06094ad5521063068707efeee2d019f9fb8be76599dc9f8c28c47752138e710d

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  module Instrumentation
    module Dalli
      module Patches
        # Module to prepend to Dalli::Server for instrumentation
        module Server
          def request(op, *args)
            operation = Utils.opname(op, multi?)
            attributes = {
              'db.system' => 'memcached',
              'net.peer.name' => hostname,
              'net.peer.port' => port
            }
            attributes['db.statement'] = Utils.format_command(operation, args) if config[:db_statement] == :include
            attributes['peer.service'] = config[:peer_service] if config[:peer_service]
            tracer.in_span(operation, attributes: attributes, kind: :client) do
              super
            end
          end

          private

          def tracer
            Dalli::Instrumentation.instance.tracer
          end

          def config
            Dalli::Instrumentation.instance.config
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-dalli-0.19.1 lib/opentelemetry/instrumentation/dalli/patches/server.rb
opentelemetry-instrumentation-dalli-0.19.0 lib/opentelemetry/instrumentation/dalli/patches/server.rb