Module: OpenTelemetry::Instrumentation::Redis
- Extended by:
- Redis
- Included in:
- Redis
- Defined in:
- lib/opentelemetry/instrumentation/redis.rb,
lib/opentelemetry/instrumentation/redis/version.rb,
lib/opentelemetry/instrumentation/redis/instrumentation.rb,
lib/opentelemetry/instrumentation/redis/patches/redis_v4_client.rb,
lib/opentelemetry/instrumentation/redis/middlewares/redis_client.rb
Overview
Contains the OpenTelemetry instrumentation for the Redis gem
Defined Under Namespace
Modules: Middlewares, Patches Classes: Instrumentation
Constant Summary collapse
- VERSION =
'0.25.7'
Instance Method Summary collapse
-
#attributes(context = nil) ⇒ Object
Returns the attributes hash representing the Redis client context found in the optional context or the current context if none is provided.
-
#context_with_attributes(attributes_hash, parent_context: Context.current) ⇒ Object
Returns a context containing the merged attributes hash, derived from the optional parent context, or the current context if one was not provided.
-
#with_attributes(attributes_hash) {|Hash, Context| ... } ⇒ Object
Activates/deactivates the merged attributes hash within the current Context, which makes the "current attributes hash" available implicitly.
Instance Method Details
#attributes(context = nil) ⇒ Object
Returns the attributes hash representing the Redis client context found in the optional context or the current context if none is provided.
26 27 28 29 |
# File 'lib/opentelemetry/instrumentation/redis.rb', line 26 def attributes(context = nil) context ||= Context.current context.value(CURRENT_ATTRIBUTES_HASH) || {} end |
#context_with_attributes(attributes_hash, parent_context: Context.current) ⇒ Object
Returns a context containing the merged attributes hash, derived from the optional parent context, or the current context if one was not provided.
36 37 38 39 |
# File 'lib/opentelemetry/instrumentation/redis.rb', line 36 def context_with_attributes(attributes_hash, parent_context: Context.current) attributes_hash = attributes(parent_context).merge(attributes_hash) parent_context.set_value(CURRENT_ATTRIBUTES_HASH, attributes_hash) end |
#with_attributes(attributes_hash) {|Hash, Context| ... } ⇒ Object
Activates/deactivates the merged attributes hash within the current Context, which makes the "current attributes hash" available implicitly.
On exit, the attributes hash that was active before calling this method will be reactivated.
50 51 52 53 |
# File 'lib/opentelemetry/instrumentation/redis.rb', line 50 def with_attributes(attributes_hash) attributes_hash = attributes.merge(attributes_hash) Context.with_value(CURRENT_ATTRIBUTES_HASH, attributes_hash) { |c, h| yield h, c } end |