Module: NewRelic::Agent::Instrumentation::Redis

Included in:
Prepend, NewRelic::Agent::Instrumentation::RedisClient::ClusterMiddleware, NewRelic::Agent::Instrumentation::RedisClient::Middleware
Defined in:
lib/new_relic/agent/instrumentation/redis/constants.rb,
lib/new_relic/agent/instrumentation/redis/chain.rb,
lib/new_relic/agent/instrumentation/redis/prepend.rb,
lib/new_relic/agent/instrumentation/redis/instrumentation.rb

Overview

This file is distributed under New Relic’s license terms. See github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. frozen_string_literal: true

Defined Under Namespace

Modules: Chain, Prepend Classes: Constants

Constant Summary collapse

INSTRUMENTATION_NAME =
NewRelic::Agent.base_name(name)

Instance Method Summary collapse

Instance Method Details

#call_pipeline_with_tracing(pipeline) ⇒ Object

Used for Redis 4.x and 3.x



23
24
25
26
27
28
# File 'lib/new_relic/agent/instrumentation/redis/instrumentation.rb', line 23

def call_pipeline_with_tracing(pipeline)
  operation = pipeline.is_a?(::Redis::Pipeline::Multi) ? Constants::MULTI_OPERATION : Constants::PIPELINE_OPERATION
  statement = ::NewRelic::Agent::Datastores::Redis.format_pipeline_commands(pipeline.commands)

  with_tracing(operation, statement: statement, database: _nr_db) { yield }
end

#call_pipelined_with_tracing(pipeline) ⇒ Object

Used for Redis 5.x+



31
32
33
34
35
36
# File 'lib/new_relic/agent/instrumentation/redis/instrumentation.rb', line 31

def call_pipelined_with_tracing(pipeline)
  operation = pipeline.flatten.include?('MULTI') ? Constants::MULTI_OPERATION : Constants::PIPELINE_OPERATION
  statement = ::NewRelic::Agent::Datastores::Redis.format_pipeline_commands(pipeline)

  with_tracing(operation, statement: statement, database: _nr_db) { yield }
end

#call_with_tracing(command, &block) ⇒ Object



15
16
17
18
19
20
# File 'lib/new_relic/agent/instrumentation/redis/instrumentation.rb', line 15

def call_with_tracing(command, &block)
  operation = command[0]
  statement = ::NewRelic::Agent::Datastores::Redis.format_command(command)

  with_tracing(operation, statement: statement, database: _nr_db) { yield }
end

#connect_with_tracingObject



11
12
13
# File 'lib/new_relic/agent/instrumentation/redis/instrumentation.rb', line 11

def connect_with_tracing
  with_tracing(Constants::CONNECT, database: _nr_db) { yield }
end