opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentati...
Riccardo Magliocchetti ab0ea0e0f9
Add support for python 3.12 (#2572)
2024-06-10 12:49:10 -07:00
..
src/opentelemetry/instrumentation/falcon Update version to 1.26.0.dev/0.47b0.dev (#2568) 2024-05-30 18:48:51 -07:00
tests HTTP transition for wsgi (#2425) 2024-04-19 10:59:05 -07:00
LICENSE fix: revert modifications to Apache license (#2429) 2024-04-22 13:23:38 -05:00
README.rst Add support for generic OTEL_PYTHON_EXCLUDED_URLS variable (#790) 2021-11-10 22:44:02 +00:00
pyproject.toml Add support for python 3.12 (#2572) 2024-06-10 12:49:10 -07:00
test-requirements-0.txt requirements: bump pytest to 7.4.4 (#2587) 2024-06-07 08:53:22 -07:00
test-requirements-1.txt requirements: bump pytest to 7.4.4 (#2587) 2024-06-07 08:53:22 -07:00
test-requirements-2.txt requirements: bump pytest to 7.4.4 (#2587) 2024-06-07 08:53:22 -07:00

README.rst

OpenTelemetry Falcon Tracing
============================

|pypi|

.. |pypi| image:: https://badge.fury.io/py/opentelemetry-instrumentation-falcon.svg
   :target: https://pypi.org/project/opentelemetry-instrumentation-falcon/

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


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:

::

    def request_hook(span, req):
        pass

    def response_hook(span, req, resp):
        pass

    FalconInstrumentation().instrument(request_hook=request_hook, response_hook=response_hook)

References
----------

* `OpenTelemetry Falcon Instrumentation <https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/falcon/falcon.html>`_
* `OpenTelemetry Project <https://opentelemetry.io/>`_
* `OpenTelemetry Python Examples <https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples>`_