Skip to main content

A wrapper for redis-py, instrumented using OpenCensus for distributed tracing and metrics

Project description

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.

https://badge.fury.io/py/ocredis.svg

Installing it

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
>>> 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'

Metrics available

  • 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

Tests can be run by using pytest, for example

pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ocredis-0.0.4.tar.gz (12.7 kB view hashes)

Uploaded source

Built Distribution

ocredis-0.0.4-py2-none-any.whl (14.3 kB view hashes)

Uploaded py2

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page