Module: Datadog::Contrib::ActiveSupport::Cache::Instrumentation
- Defined in:
- lib/ddtrace/contrib/active_support/cache/instrumentation.rb
Overview
Defines instrumentation for ActiveSupport caching
rubocop:disable Lint/RescueException
Defined Under Namespace
Modules: Delete, Fetch, FetchMulti, Read, ReadMulti, Write, WriteMulti
Class Method Summary
collapse
Class Method Details
.finish_trace_cache(payload) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/ddtrace/contrib/active_support/cache/instrumentation.rb', line 42
def finish_trace_cache(payload)
tracing_context = payload.fetch(:tracing_context)
span = tracing_context[:dd_cache_span]
return unless span && !span.finished?
begin
if defined?(::Rails)
store, = *Array.wrap(::Rails.configuration.cache_store).flatten
span.set_tag(Ext::TAG_CACHE_BACKEND, store)
end
normalized_key = ::ActiveSupport::Cache.expand_cache_key(payload.fetch(:key))
cache_key = Datadog::Utils.truncate(normalized_key, Ext::QUANTIZE_CACHE_MAX_KEY_SIZE)
span.set_tag(Ext::TAG_CACHE_KEY, cache_key)
span.set_error(payload[:exception]) if payload[:exception]
ensure
span.finish
end
rescue StandardError => e
Datadog.logger.debug(e.message)
end
|
.finish_trace_cache_multi(payload) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/ddtrace/contrib/active_support/cache/instrumentation.rb', line 67
def finish_trace_cache_multi(payload)
tracing_context = payload.fetch(:tracing_context)
span = tracing_context[:dd_cache_span]
return unless span && !span.finished?
begin
if defined?(::Rails)
store, = *Array.wrap(::Rails.configuration.cache_store).flatten
span.set_tag(Ext::TAG_CACHE_BACKEND, store)
end
normalized_keys = payload.fetch(:keys, []).map do |key|
::ActiveSupport::Cache.expand_cache_key(key)
end
cache_keys = Datadog::Utils.truncate(normalized_keys, Ext::QUANTIZE_CACHE_MAX_KEY_SIZE)
span.set_tag(Ext::TAG_CACHE_KEY_MULTI, cache_keys)
span.set_error(payload[:exception]) if payload[:exception]
ensure
span.finish
end
rescue StandardError => e
Datadog.logger.debug(e.message)
end
|
.start_trace_cache(payload) ⇒ Object