Skip to main content

Library to correctly pass current OpenTracing span to Cassandra

Project description


PyPI PyPI version PyPI

When do I use it?

When I'm using the following technologies:

And you want to attach your traces to Cassandra's requests.

Note: so far only Jaeger tracing and MockTracer are supported. I mean, theoretically every opentracing-compatible framework is supported, but only Jaeger's tracing enables to select which query to trace or not.

In case that you're not using Jaeger or MockTracer, every single query will be sent with a tracing request, which may negatively impact your performance, Cassandra-wise.

If you have an issue with that, please file an issue with a description of what it is that you're using for tracing.

A relevant warning will be shown as well.


Just do the following:

from python_cassandra_jaeger import SessionTracer
from cassandra.cluster import Cluster

from .tracing import tracer

c = Cluster([''])
s = c.connect('keyspace')
st = SessionTracer(s, tracer)

st.execute('SELECT * FROM table')

And you keep on utilizing st instead of s. This will automatically execute tracing when your span is being traced.

Just remember to match your tracing key with Cassandra's JAEGER_TRACE_KEY.

What does it do?

It hijacks session.execute, grabs the current span, determines if sampling is active for this span (currently works only with Jaeger) and if it is so, starts a new child span, attaches it's ID to custom_payload and enables tracing for the request.

Additionally metricizing your queries

Added in v0.4: You can also metrify how long did your queries take to execute, say:

from satella.instrumentation.metrics import getMetric

met_sum = getMetric('cassandra.query.time.summary', 'summary')
s = c.connect('keyspace')
st = SessionTracer(s, tracer, metric=met_sum)



  • added an option to metricize the queries
  • added support for MockTracker


  • a warning will be shown with unsupported tracing mechanism


  • improved reporting when arguments is a dict

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

python-cassandra-jaeger-0.4.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distributions

python_cassandra_jaeger-0.4-py3.8.egg (4.0 kB view hashes)

Uploaded Source

python_cassandra_jaeger-0.4-py2.py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 2 Python 3

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