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.

Files for ocredis, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size ocredis-0.0.4-py2-none-any.whl (14.3 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size ocredis-0.0.4.tar.gz (12.7 kB) File type Source Python version None Upload date Hashes View

Supported by

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