OpenTelemetry Instrumentation for Django
Project description
This library allows tracing requests for Django applications.
Installation
pip install opentelemetry-instrumentation-django
Configuration
Exclude lists
To exclude certain URLs from being tracked, set the environment variable OTEL_PYTHON_DJANGO_EXCLUDED_URLS with comma delimited regexes representing which URLs to exclude.
For example,
export OTEL_PYTHON_DJANGO_EXCLUDED_URLS="client/.*/info,healthcheck"
will exclude requests such as https://site/client/123/info and https://site/xyz/healthcheck.
Request attributes
To extract certain attributes from Django’s request object and use them as span attributes, set the environment variable OTEL_PYTHON_DJANGO_TRACED_REQUEST_ATTRS to a comma delimited list of request attribute names.
For example,
export OTEL_PYTHON_DJANGO_TRACED_REQUEST_ATTRS='path_info,content_type'
will extract path_info and content_type attributes from every traced request and add them as span attritbues.
Django Request object reference: https://docs.djangoproject.com/en/3.1/ref/request-response/#attributes
Request and Response hooks
The instrumentation supports specifying request and response hooks. These are functions that get called back by the instrumentation right after a Span is created for a request and right before the span is finished while processing a response. The hooks can be configured as follows:
def request_hook(span, request): pass def response_hook(span, request, response): pass DjangoInstrumentation().instrument(request_hook=request_hook, response_hook=response_hook)
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for opentelemetry-instrumentation-django-0.23b2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c46481899c9e90c5829a9a15da6b9a45dbf8f3ae2b204ac785daf4582037b41a |
|
MD5 | 0e7a0079392bfdb2cbe989d05d3e94b6 |
|
BLAKE2b-256 | 71250258c3df977c3220c0ef8b55873227c64db11688e7be90aaafc793e66eee |
Hashes for opentelemetry_instrumentation_django-0.23b2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fda9313f2be155a5d09d2c6213d09b0df96bacb2e603860a7b4af84f5a260592 |
|
MD5 | cbcaccd3119c94027c6ebeea49286fa3 |
|
BLAKE2b-256 | 312bc63a77c9f0e40167132ffda6d849ee41d600ca30310e395cdd05eb9598a6 |