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 Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page