basictracer is a Python implementation of the OpenTracing API, providing a simple, in-memory tracer suitable for development and testing. It allows applications to instrument code with spans, logs, and baggage, adhering to the OpenTracing specification. The current version is 3.2.0, and its release cadence is infrequent, with the last major update in 2021.
pip install basictracerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize `BasicTracer` with an `InMemoryRecorder`, set it as the global OpenTracing tracer, and create a basic span with logs. It also shows how to retrieve the recorded spans. Remember that `BasicTracer` stores spans in memory and does not export them.
Update your code to handle `SpanContextCorruptedException` when calling `TextPropagator.extract`. Ensure input headers are correctly formatted according to OpenTracing standards.
Ensure the `references` argument passed to `Tracer.start_span` is an iterable of `opentracing.Reference` objects (e.g., `opentracing.ChildOf(parent_span)` or `opentracing.FollowsFrom(span_context)`).
For production environments requiring distributed tracing and data persistence, integrate your application with a full-featured OpenTracing-compatible tracer like Jaeger, Zipkin, or AWS X-Ray.
If using Python 3.5 or newer, ensure you are using `basictracer` version 3.1.0 or higher. If you must use an older Python, downgrade `basictracer` to a compatible version (e.g., `<3.1.0`).
Verify that the incoming HTTP headers or other carrier data contain valid OpenTracing-compatible tracing information. If malformed headers are possible, wrap the extraction call in a `try...except SpanContextCorruptedException` block.
Correctly use `opentracing.ChildOf(parent_span)` or `opentracing.FollowsFrom(span_context)` to create `Reference` objects, and pass them within a list or tuple to the `references` argument, e.g., `tracer.start_span('child', references=[opentracing.ChildOf(parent_span)])`.Upgrade your Python environment to version 3.5 or higher. Alternatively, if you are stuck on an older Python version, install an older `basictracer` release (e.g., `pip install 'basictracer<3.1.0'`).