Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/opencensus-integrations/ocredispy
OpenCensus wrapper for redis-py
https://github.com/opencensus-integrations/ocredispy
caching distributed-tracing metrics observability opencensus redis redis-client tracing
Last synced: 3 months ago
JSON representation
OpenCensus wrapper for redis-py
- Host: GitHub
- URL: https://github.com/opencensus-integrations/ocredispy
- Owner: opencensus-integrations
- License: apache-2.0
- Created: 2018-10-01T08:59:58.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-22T14:12:23.000Z (9 months ago)
- Last Synced: 2024-07-25T19:41:18.348Z (4 months ago)
- Topics: caching, distributed-tracing, metrics, observability, opencensus, redis, redis-client, tracing
- Language: Python
- Homepage: https://opencensus.io/integrations/redis/python/redispy/
- Size: 24.4 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
ocredis
=======ocredis is a wrapper for the popular [redis-py](https://github.com/andymccurdy/redis-py)
ocredis provides observability using OpenCensus for distributed tracing and metrics.
.. image:: https://badge.fury.io/py/ocredis.svg
:target: https://pypi.org/project/ocredis/Installing it
-------------.. code-block:: bash
pip install ocredis
Using it
--------You can initialize exactly how you would for redis.Redis.
In fact it is meant to be a drop replacement.* Change the import statement from
.. code-block:: pycon
>>> import redis
to.. code-block:: pycon
>>> import ocredis
* Change the client initialization from
.. code-block:: pycon
>>> client = redis.Redis(host=host, port=port)
to.. code-block:: pycon
>>> client = ocredis.OcRedis(host=host, port=port)`
and obviously enabling OpenCensus metrics and exporters as per https://opencensus.io/exporters/supported-exporters/python/
.. code-block:: pycon
>>> ocredis.register_views()
and the rest is trivial to use then.
For example
.. code-block:: pycon
>>> import ocredis
>>> ocredis.register_views()
>>> r = ocredis.OcRedis(host='localhost', port=6379)
>>> r.set('foo', 'bar')
True
>>> r.get('foo')
'bar'Metrics available
------------------ calls
- latency
- key_length
- value_length.. csv-table::
:header: "Metric", "View Name", "Unit", "Tags"
:widths: 20, 20, 20, 20"Latency", "redispy/latency", "ms", "'error', 'method', 'status'"
"Calls", "redispy/calls", "1", "'error', 'method', 'status'"
"Key lengths", "redispy/key_length", "By", "'error', 'method', 'status'"
"Value lengths", "redispy/value_length", "By", "'error', 'method', 'status'"Tests
-----
Tests can be run by using pytest, for example.. code-block:: bash
pytest