Skip to main content

Library to correctly pass current OpenTracing span to Cassandra

Project description

python-cassandra-jaeger

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.

Usage

Just do the following:

from python_cassandra_jaeger import SessionTracer
from cassandra.cluster import Cluster

from .tracing import tracer

c = Cluster(['127.0.0.1'])
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)

History

v0.4

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

v0.3

  • a warning will be shown with unsupported tracing mechanism

v0.2

  • 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 details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Egg

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

Uploaded Python 2Python 3

File details

Details for the file python-cassandra-jaeger-0.4.tar.gz.

File metadata

  • Download URL: python-cassandra-jaeger-0.4.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.0

File hashes

Hashes for python-cassandra-jaeger-0.4.tar.gz
Algorithm Hash digest
SHA256 c3d912761785ca5160c2d6364b2c42c2d001feba4167f200748dec02d580144f
MD5 125a154c6dc571f9f5549ba4c7b5151b
BLAKE2b-256 efb68b71f1a88b89db0e85a1f45bf69a6d30789a01c9a8f3b8cc16e8aae30f6b

See more details on using hashes here.

File details

Details for the file python_cassandra_jaeger-0.4-py3.8.egg.

File metadata

  • Download URL: python_cassandra_jaeger-0.4-py3.8.egg
  • Upload date:
  • Size: 4.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.0

File hashes

Hashes for python_cassandra_jaeger-0.4-py3.8.egg
Algorithm Hash digest
SHA256 89ef8130a6cb8cf0c915776f9544fcbbf52b210689eb53009b722e65f87efc7b
MD5 9f3e34da99c981da0eea5e2c6b19590b
BLAKE2b-256 996c64294c2de7f0c307ef0af4d3a01ff02b10f73438b66d7c5e572a3e5503fd

See more details on using hashes here.

File details

Details for the file python_cassandra_jaeger-0.4-py2.py3-none-any.whl.

File metadata

  • Download URL: python_cassandra_jaeger-0.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.0

File hashes

Hashes for python_cassandra_jaeger-0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d260b20d4958ead83cbfc80bdce9f69cb6309293155b21b3354ea4cdf661c3a3
MD5 6ed1d6217ab189763a6b41fd2e412363
BLAKE2b-256 3db89aea52711bd07d1a2f01422e52c9c1843c4fe654d1ce4064ff11ec336ed4

See more details on using hashes here.

Supported by

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