Skip to main content

otel-log-span-status

Lint Test

Marks the active OpenTelemetry span as ERROR whenever an error-level log is emitted. Patterns listed in a YAML config are exempt, so expected or handled errors don't mark the span.

Status: early development.

Animated walkthrough: why tail samplers drop traces whose errors only reach the logs, installing otel-log-span-status, a four-line setup that marks the active span as ERROR, and YAML ignore rules that keep expected errors from doing the same

Install

pip install otel-log-span-status

Requires Python 3.10+ and opentelemetry-api 1.20+. You also need an OpenTelemetry SDK configured in your service; this library only sets span status.

Usage

import otel_log_span_status

otel_log_span_status.install("otel-log-span-status.yaml")
# otel-log-span-status.yaml
ignore:
  - logger: "urllib3.*"                      # logger name glob
  - message_template: "Retrying request %s"  # exact match on the unformatted message
  - logger: "payments.*"                     # fields within one rule must all match
    message_regex: "card declined"

The config file is optional. install() with no path treats every error log equally: each one marks the span. If you pass a path, the file must exist and be valid, or install() raises. install() attaches a handler to the root logger. Records from any logger that propagates to root are checked. To skip a single call without a config rule, pass extra={"span_error": False}.

Why This Exists

In OpenTelemetry, tail samplers rely on StatusCode.ERROR to decide which traces to keep. In real-world Python services, however, mutating span statuses manually is painful.

This creates an expensive gap between your logs and your traces:

  • Default OTel (Blind Sampling): Caught errors are logged, but the span status remains UNSET. Your tail sampler assumes the trace is healthy and drops it—destroying the exact traces you need during an outage.
  • Naïve Log-to-Span Hook (Cost Explosion): Automatically setting the active span to ERROR on every logger.error() call poisons healthy traces. Third-party libraries (urllib3, botocore) and handled retries emit thousands of non-fatal error logs, forcing your tail sampler to store millions of false-positive traces.

otel-log-span-status sits inside the Python runtime and bridges logging with OpenTelemetry. It promotes logger.error() calls to StatusCode.ERROR on the active span, while evaluating a fast, service-specific YAML ignore list (by logger name, raw message template, or regex) so noisy false positives never trigger tail sampling.

License

Apache-2.0. See LICENSE.

Metadata

Release files for otel-log-span-status 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for otel-log-span-status 0.1.0
File Size Uploaded Provenance Actions
otel_log_span_status-0.1.0.tar.gz 12.2 kB With provenance Details for otel_log_span_status-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for otel-log-span-status 0.1.0
File Interpreter ABI Platform Actions
otel_log_span_status-0.1.0-py3-none-any.whl Python 3 none any Details for otel_log_span_status-0.1.0-py3-none-any.whl

Total release size: 22.4 kB

Release files / otel_log_span_status-0.1.0.tar.gz

Download URL otel_log_span_status-0.1.0.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
95499f714f2d3f756a75521eff8693c149d9cddec4725b9a49ad75746fd8608b
BLAKE2b-256 checksum
How to use checksums
6e0604f6754ff54b198275119b0e20676ffd7cd72e6eb8ffd80e2e660e5ab9e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / otel_log_span_status-0.1.0-py3-none-any.whl

Download URL otel_log_span_status-0.1.0-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b78ad8882addcd5de76900116f068e653cc606e80362eafd73d839958fe72c57
BLAKE2b-256 checksum
How to use checksums
921460bac2edbd0c435748a83308b7d185b5f2fe4fd603177bf7b37caa9d88aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Security for otel-log-span-status 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for otel_log_span_status-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page