-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Show cache alias instead of backend repr in calls table #2219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ | |
| ] | ||
|
|
||
|
|
||
| def _monkey_patch_method(cache, name): | ||
| def _monkey_patch_method(cache, name, alias): | ||
| original_method = getattr(cache, name) | ||
|
|
||
| @functools.wraps(original_method) | ||
|
|
@@ -39,15 +39,15 @@ def wrapper(*args, **kwargs): | |
| if panel is None: | ||
| return original_method(*args, **kwargs) | ||
| else: | ||
| return panel._record_call(cache, name, original_method, args, kwargs) | ||
| return panel._record_call(cache, alias, name, original_method, args, kwargs) | ||
|
|
||
| setattr(cache, name, wrapper) | ||
|
|
||
|
|
||
| def _monkey_patch_cache(cache): | ||
| def _monkey_patch_cache(cache, alias): | ||
| if not hasattr(cache, "_djdt_patched"): | ||
| for name in WRAPPED_CACHE_METHODS: | ||
| _monkey_patch_method(cache, name) | ||
| _monkey_patch_method(cache, name, alias) | ||
federicobond marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| cache._djdt_patched = True | ||
|
|
||
|
|
||
|
|
@@ -95,7 +95,7 @@ def wrapper(self, alias): | |
| cache = original_method(self, alias) | ||
| panel = cls.current_instance() | ||
| if panel is not None: | ||
| _monkey_patch_cache(cache) | ||
| _monkey_patch_cache(cache, alias) | ||
| cache._djdt_panel = panel | ||
| return cache | ||
|
|
||
|
|
@@ -138,7 +138,7 @@ def _store_call_info( | |
| } | ||
| ) | ||
|
|
||
| def _record_call(self, cache, name, original_method, args, kwargs): | ||
| def _record_call(self, cache, alias, name, original_method, args, kwargs): | ||
| # Some cache backends implement certain cache methods in terms of other cache | ||
| # methods (e.g. get_or_set() in terms of get() and add()). In order to only | ||
| # record the calls made directly by the user code, set the cache's _djdt_panel | ||
|
|
@@ -161,7 +161,7 @@ def _record_call(self, cache, name, original_method, args, kwargs): | |
| kwargs=kwargs, | ||
| trace=get_stack_trace(skip=2), | ||
| template_info=get_template_info(), | ||
| backend=cache, | ||
| backend=alias, | ||
| ) | ||
| return value | ||
|
|
||
|
|
@@ -194,9 +194,10 @@ def enable_instrumentation(self): | |
| # requests. The monkey patch of CacheHander.create_connection() installed in | ||
| # the .ready() method will ensure that any new cache connections that get opened | ||
| # during this request will also be monkey patched. | ||
| for cache in caches.all(initialized_only=True): | ||
| _monkey_patch_cache(cache) | ||
| cache._djdt_panel = self | ||
| for alias in caches: | ||
| if hasattr(caches._connections, alias): | ||
|
||
| _monkey_patch_cache(caches[alias], alias) | ||
| caches[alias]._djdt_panel = self | ||
| # Mark this panel instance as the current one for the active thread/async task | ||
| # context. This will be used by the CacheHander.create_connection() monkey | ||
| # patch. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.