#36879: Add Django cache identification to Redis client metadata
-------------------------------------+-------------------------------------
     Reporter:  Vasil Chomakov       |                    Owner:  (none)
         Type:  New feature          |                   Status:  new
    Component:  Core (Cache system)  |                  Version:  dev
     Severity:  Normal               |               Resolution:
     Keywords:  redis cache          |             Triage Stage:
  observability                      |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Zachary W):

 I poked around and got a working solution. Although in future versions of
 `redis-py`, `lib_name` and `lib_version` are [https://github.com/redis
 /redis-
 py/blob/6063a86b3fa58fc504f84a98f42cee0954c95cbd/redis/connection.py#L658
 deprecated], `DriverInfo` is not available for latest `redis-py` release
 `v7.1.0`.

 In `django/core/cache/backends/redis.py`:

 {{{
 class RedisCacheClient:
     def _get_connection_class(self, lib):
         class DjangoConnection(lib.Connection):
             def __init__(self, *args, **kwargs):
                 super().__init__(*args, **kwargs)
                 self.lib_name = "django"
                 self.lib_version = django.get_version()

         return DjangoConnection
    def __init__(
         servers,
         serializer=None,
         pool_class=None,
         parser_class=None,
         **options,
     ):
     ...

     self._connection_class = self._get_connection_class(self._lib)
     ...
     self._pool_options = {
             "parser_class": parser_class,
             "connection_class": self._connection_class,
             **options,
         }
 }}}


 I can make a PR once this ticket is accepted. And we'll have to update
 again once `DriverInfo` for `redis-py` is released.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36879#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019becfeb3e1-e818ea20-b320-4fee-9ec9-57c0020464f4-000000%40eu-central-1.amazonses.com.

Reply via email to