module Datadog::Tracing::Contrib::ActiveSupport::Cache::Instrumentation
def enabled?
def enabled? Tracing.enabled? && Datadog.configuration.tracing[:active_support][:enabled] end
def nested_multiread?
def nested_multiread? current_span = Tracing.active_span current_span && current_span.name == Ext::SPAN_CACHE && current_span.resource == Ext::RESOURCE_CACHE_MGET end
def nested_read?
Instrument both does not add any value.
In most of the cases, `#fetch()` and `#read()` calls are nested.
def nested_read? current_span = Tracing.active_span current_span && current_span.name == Ext::SPAN_CACHE && current_span.resource == Ext::RESOURCE_CACHE_GET end
def set_cache_key(span, single_key, multi_key)
def set_cache_key(span, single_key, multi_key) if multi_key resolved_key = multi_key.map { |key| ::ActiveSupport::Cache.expand_cache_key(key) } cache_key = Core::Utils.truncate(resolved_key, Ext::QUANTIZE_CACHE_MAX_KEY_SIZE) span.set_tag(Ext::TAG_CACHE_KEY_MULTI, cache_key) else resolved_key = ::ActiveSupport::Cache.expand_cache_key(single_key) cache_key = Core::Utils.truncate(resolved_key, Ext::QUANTIZE_CACHE_MAX_KEY_SIZE) span.set_tag(Ext::TAG_CACHE_KEY, cache_key) end end
def trace(action, store, key: nil, multi_key: nil)
-
multi_key
(Array
) -- list of redis cache keys. Used for actions with a multiple key locators. -
key
(Object
) -- redis cache key. Used for actions with a single key locator. -
action
(String
) -- type of cache operation. Will be set as the span resource.
def trace(action, store, key: nil, multi_key: nil) return yield unless enabled? # create a new ``Span`` and add it to the tracing context Tracing.trace( Ext::SPAN_CACHE, span_type: Ext::SPAN_TYPE_CACHE, service: Datadog.configuration.tracing[:active_support][:cache_service], resource: action ) do |span| span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT) span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_CACHE) if span.service != Datadog.configuration.service span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service) end span.set_tag(Ext::TAG_CACHE_BACKEND, store) if store set_cache_key(span, key, multi_key) yield end end