Skip to main content

Django Observability

A production-ready Django middleware for comprehensive observability, integrating OpenTelemetry for distributed tracing, Prometheus for metrics, and structured logging with correlation ID tracking.

Features

  • Distributed Tracing: Track request flows across services using OpenTelemetry with support for Jaeger, Zipkin, or OTLP exporters.
  • Metrics Collection: Expose Prometheus metrics for HTTP requests, response sizes, and active request counts.
  • Structured Logging: Log requests, responses, and exceptions in JSON format with correlation IDs.
  • Async Support: Compatible with synchronous and asynchronous Django views.
  • Configurable: Customize via Django settings or environment variables.
  • Non-Intrusive: Minimal performance overhead with graceful error handling.

Installation

Install the package:

pip install django-observability

Add to INSTALLED_APPS in settings.py:

INSTALLED_APPS = [
    ...,
    'django_observability',
]

Add the middleware to MIDDLEWARE in settings.py:

MIDDLEWARE = [
    ...,
    'django_observability.middleware.ObservabilityMiddleware',
]

Configure in settings.py (optional):

DJANGO_OBSERVABILITY = {
    'TRACING_ENABLED': True,
    'METRICS_ENABLED': True,
    'LOGGING_ENABLED': True,
    'SERVICE_NAME': 'my-django-app',
    'OTEL_EXPORTER': {
        'endpoint': 'http://localhost:4317',
        'protocol': 'grpc',
    },
}

Add the metrics endpoint in urls.py:

from django.urls import path
from django_observability.metrics import metrics_view

urlpatterns = [
    path('metrics/', metrics_view, name='metrics'),
]

Documentation

Detailed guides are available in the docs/ folder:

Examples

  • examples/basic_django_app/: Minimal Django app showcasing observability setup.
  • examples/advanced_config/: Advanced configuration with custom metrics and tracing.

Requirements

  • Python 3.10+
  • Django 3.2 to 5.x
  • See requirements/base.txt for full dependencies.

Contributing

Contributions are welcome! See CONTRIBUTING.md for details on setting up the development environment, code style, and submitting pull requests.

License

MIT License. See LICENSE for details.

Metadata

Release files for django-observability 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 django-observability 0.1.0
File Size Uploaded Provenance Actions
django_observability-0.1.0.tar.gz 30.2 kB Without provenance Details for django_observability-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-observability 0.1.0
File Interpreter ABI Platform Actions
django_observability-0.1.0-py3-none-any.whl Python 3 none any Details for django_observability-0.1.0-py3-none-any.whl

Total release size: 53.5 kB

Release files / django_observability-0.1.0.tar.gz

Download URL django_observability-0.1.0.tar.gz
Size 30.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3a85b7e5f0bbb1465f2b05e3cb5295ab4f963418542d280d22fda985ca8831d6
BLAKE2b-256 checksum
How to use checksums
bdb88047972bba79ddf777dced2ca4cc92e941c4cbdf8c54a533406b5ff8b39a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

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

Download URL django_observability-0.1.0-py3-none-any.whl
Size 23.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
93d09fbacde8492ba2aaa3a92312acdb360fcdf86d0323a010595c914b6c28a1
BLAKE2b-256 checksum
How to use checksums
eca6c98673cf36cab15f3d13ff79534ed86a825f6490811cd92e81c4503d2876
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Security for django-observability 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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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 No 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