Sha256: f55346ca28777e247a02c8fa267b2335543e2999bc6eef89459ca12cbcb564ac

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 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',
              'db.statement' => Utils.format_command(operation, args),
              'net.peer.name' => hostname,
              'net.peer.port' => port
            }
            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

9 entries across 9 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-dalli-0.18.1 lib/opentelemetry/instrumentation/dalli/patches/server.rb
opentelemetry-instrumentation-dalli-0.18.0 lib/opentelemetry/instrumentation/dalli/patches/server.rb
opentelemetry-instrumentation-dalli-0.17.0 lib/opentelemetry/instrumentation/dalli/patches/server.rb
opentelemetry-instrumentation-dalli-0.16.0 lib/opentelemetry/instrumentation/dalli/patches/server.rb
opentelemetry-instrumentation-dalli-0.15.0 lib/opentelemetry/instrumentation/dalli/patches/server.rb
opentelemetry-instrumentation-dalli-0.14.0 lib/opentelemetry/instrumentation/dalli/patches/server.rb
opentelemetry-instrumentation-dalli-0.13.0 lib/opentelemetry/instrumentation/dalli/patches/server.rb
opentelemetry-instrumentation-dalli-0.12.0 lib/opentelemetry/instrumentation/dalli/patches/server.rb
opentelemetry-instrumentation-dalli-0.11.0 lib/opentelemetry/instrumentation/dalli/patches/server.rb