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.
pip install ocredis
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
>>> import redis
to
>>> import ocredis
- Change the client initialization from
>>> client = redis.Redis(host=host, port=port)
to
>>> client = ocredis.OcRedis(host=host, port=port)`
and obviously enabling OpenCensus metrics and exporters as per https://opencensus.io/exporters/supported-exporters/python/
>>> ocredis.register_views()
and the rest is trivial to use then.
For example
>>> import ocredis
>>> ocredis.register_views()
>>> r = ocredis.OcRedis(host='localhost', port=6379)
>>> r.set('foo', 'bar')
True
>>> r.get('foo')
'bar'
- calls
- latency
- key_length
- value_length
Metric | View Name | Unit | Tags |
---|---|---|---|
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 can be run by using pytest, for example
pytest