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.24b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8df7dd36c7fb991f71cc32d120449574bcbc263f1c699b66cb75d0b075643ff5 |
|
MD5 | e7cd18f74388c651e2309d58fdce0fa7 |
|
BLAKE2b-256 | a1e23aee881a83c8daa0e08e31f9f17616942887ea1547c8016ff57e2be8c9f4 |
Hashes for opentelemetry_instrumentation_django-0.24b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7141c26f233fc65eb4c824e42e1c41a5489c2b1026873512742de19f9886e300 |
|
MD5 | b8665662fa2c7b776d1f15cdf52afb77 |
|
BLAKE2b-256 | 13b1ce0ab89fa3d4843b2546d323cdf27018b727f6bc5faf2e3258f3dade09e3 |