opencensus-ext-logging
OpenCensus logging Integration
What it is and what it does
opencensus-ext-logging is a plugin that integrates Python's standard logging module with OpenCensus distributed tracing. It automatically adds trace ID, span ID, and sampling flag to every log record, enabling logs to be correlated with traces across distributed systems. This is useful when you need to follow a single request through multiple services and want both trace and log data to reference the same context.
The integration works by hooking into the logging system after you call config_integration.trace_integrations(['logging']). Any logger created after that point will have access to traceId, spanId, and traceSampled attributes in its format string. The package depends only on opencensus itself and has low install friction, but it is no longer actively maintained—the last release was in October 2021, and the parent repository is archived.
Use it for:
- Correlate application logs with distributed traces in microservices by including trace IDs in log output.
- Debug multi-service requests by matching log entries to their corresponding trace spans across systems.
- Format log messages to include trace context for centralized logging platforms that support trace-log correlation.
- Verify which requests were sampled by including the sampling flag in logs alongside trace data.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Enriches Python log records with OpenCensus trace context (trace ID, span ID, sampling flag) to correlate logs with distributed traces.
Yes, if you are already using OpenCensus for tracing and need log correlation—the integration is straightforward and permissively licensed. However, be aware the package is abandoned (last release October 2021) and may not be compatible with recent Python or opencensus versions. Consider whether your tracing infrastructure still supports OpenCensus or whether you should migrate to a maintained alternative like OpenTelemetry.
Install
opencensus-ext-logging on PyPI
pip
pip install opencensus-ext-logginguv
uv add opencensus-ext-loggingpoetry
poetry add opencensus-ext-loggingInstalling opencensus-ext-logging
Before you install
Low install friction with a single runtime dependency on opencensus. However, the package is abandoned as of 2021-10-05 with no recent maintenance, though the repository was archived and last commit is recent (2025-06-12), suggesting the parent project may still have minimal activity.
License in practice
Licensed under Apache-2.0 (permissive), allowing use in most commercial and open-source projects without significant restrictions.
Quickstart
pip install opencensus-ext-logging
import logging
from opencensus.trace import config_integration
from opencensus.trace.samplers import AlwaysOnSampler
from opencensus.trace.tracer import Tracer
config_integration.trace_integrations(['logging'])
logging.basicConfig(format='%(asctime)s traceId=%(traceId)s spanId=%(spanId)s %(message)s')
tracer = Tracer(sampler=AlwaysOnSampler())
logger = logging.getLogger(__name__)
with tracer.span(name='hello'):
logger.warning('In the span')
Requires opencensus to be installed and configured; loggers must be created after calling config_integration.trace_integrations(['logging']) for enrichment to take effect.
Verify before relying
- Whether the package works reliably with Python versions beyond 3.9 (classifiers list up to 3.9 but no explicit requires_python constraint).
- Current compatibility with modern opencensus versions and whether breaking changes have occurred since the 2021 release.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — opencensus |
| Maintenance | abandoned — 1,774 days since the last release |
| Last repo commit | (repository archived) |
| First released | |
| Downloads | 484,731/month — #6,402 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: opencensus_ext_logging-0.1.1-py2.py3-none-any.whl
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
opencensusOpenCensus provides distributed tracing and…
permissive · top 1,000 on PyPI
opencensus-ext-requestsIntegrates OpenCensus distributed tracing with…
permissive · top 15,000 on PyPI
opencensus-ext-flaskAdds distributed tracing instrumentation to…
permissive · top 15,000 on PyPI
opencensus-ext-azureExports logs, metrics, and traces from Python…
permissive · top 5,000 on PyPI
opencensus-contextProvides in-process context propagation for…
permissive · top 1,000 on PyPI
opentelemetry-instrumentation-mcpAdds distributed tracing to MCP (Model Context…
permissive · top 5,000 on PyPI
azure-core-tracing-opentelemetryIntegrates Azure SDK clients with OpenTelemetry…
unclear · top 5,000 on PyPI
opentelemetry-instrumentation-haystackAdds distributed tracing to Haystack LLM…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-structlogIntegrates structlog logging with OpenTelemetry…
permissive · top 15,000 on PyPI
ovs-dbgProvides command-line tools to parse, filter,…
permissive · top 15,000 on PyPI