Falcon instrumentation for OpenTelemetry
Project description
This library builds on the OpenTelemetry WSGI middleware to track web requests in Falcon applications.
Installation
pip install opentelemetry-instrumentation-falcon
Configuration
Exclude lists
To exclude certain URLs from being tracked, set the environment variable OTEL_PYTHON_FALCON_EXCLUDED_URLS (or OTEL_PYTHON_EXCLUDED_URLS as fallback) with comma delimited regexes representing which URLs to exclude.
For example,
export OTEL_PYTHON_FALCON_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 Falcon’s request object and use them as span attributes, set the environment variable OTEL_PYTHON_FALCON_TRACED_REQUEST_ATTRS to a comma delimited list of request attribute names.
For example,
export OTEL_PYTHON_FALCON_TRACED_REQUEST_ATTRS='query_string,uri_template'
will extract path_info and content_type attributes from every traced request and add them as span attritbues.
Falcon Request object reference: https://falcon.readthedocs.io/en/stable/api/request_and_response.html#id1
Usage
import falcon
from opentelemetry.instrumentation.falcon import FalconInstrumentor
FalconInstrumentor().instrument()
app = falcon.App()
class HelloWorldResource(object):
def on_get(self, req, resp):
resp.text = 'Hello World'
app.add_route('/hello', HelloWorldResource())
Request/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:
from opentelemetry.instrumentation.falcon import FalconInstrumentor
def request_hook(span, req):
pass
def response_hook(span, req, resp):
pass
FalconInstrumentor().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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opentelemetry_instrumentation_falcon-0.61b0.tar.gz.
File metadata
- Download URL: opentelemetry_instrumentation_falcon-0.61b0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b64fde2edea0c5602c62f8a438d4e248ee5461140c0df670113fa92c41e292d
|
|
| MD5 |
3bce303f07a8a6d318d7f52154a5f1d5
|
|
| BLAKE2b-256 |
2088d20d9508e047548495737305aca01391713ae5e913b90b23a6818f5a7260
|
File details
Details for the file opentelemetry_instrumentation_falcon-0.61b0-py3-none-any.whl.
File metadata
- Download URL: opentelemetry_instrumentation_falcon-0.61b0-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daf8e8f135bc3c4d2990edb35d4a3cdc7d7ea27fc221abbdabb27ff9b362d4fe
|
|
| MD5 |
3628392b089a48cab0f31b59badf4d96
|
|
| BLAKE2b-256 |
8b6402a5fcfed927b0ca4a005de9ddd437ccab846fe5363e515ca0f78e205e4b
|