You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cache's cached and memoize decorators should call the public self.get and self.set methods rather than internal self.cache.get and self.cache.set.
I am trying to use the ddtrace package to enable Datadog APM traces on flask-caching processes. ddtrace works by subclassing the Cache class and wrapping its methods in some tracing code. For many cache methods (get, set, add, etc) this works fine. However, Cache's cached and memoize decorators (which we use extensively in our project) are calling an internal self.cache.get() method rather than the public (subclassable) self.get() method, so ddtrace's tracing hooks aren't being exercised (and those flask-caching gets and sets aren't showing up in Datadog).
This problem is not solvable (as far as I can tell) without changes to Flask-Caching.
The default implementation of self.get is just to call self.cache.get (ditto for self.set), so for people not subclassing Cache there shouldn't be any difference.
Only downside to this proposal I can see is if someone has a subclass of Cache with their own implementations of get and set and they really don't want their custom stuff to get exercised when gets and sets are happening as part of the cached and memoize decorators. I'd guess more often than not people would want their custom versions to be called though, so this proposed change may well have benefits beyond ddtrace.
The text was updated successfully, but these errors were encountered:
Cache's
cached
andmemoize
decorators should call the publicself.get
andself.set
methods rather than internalself.cache.get
andself.cache.set
.I am trying to use the ddtrace package to enable Datadog APM traces on flask-caching processes. ddtrace works by subclassing the
Cache
class and wrapping its methods in some tracing code. For many cache methods (get, set, add, etc) this works fine. However, Cache'scached
andmemoize
decorators (which we use extensively in our project) are calling an internalself.cache.get()
method rather than the public (subclassable)self.get()
method, so ddtrace's tracing hooks aren't being exercised (and those flask-caching gets and sets aren't showing up in Datadog).This problem is not solvable (as far as I can tell) without changes to Flask-Caching.
The default implementation of
self.get
is just to callself.cache.get
(ditto forself.set
), so for people not subclassingCache
there shouldn't be any difference.Only downside to this proposal I can see is if someone has a subclass of
Cache
with their own implementations ofget
andset
and they really don't want their custom stuff to get exercised when gets and sets are happening as part of thecached
andmemoize
decorators. I'd guess more often than not people would want their custom versions to be called though, so this proposed change may well have benefits beyond ddtrace.The text was updated successfully, but these errors were encountered: