mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-08-05 22:09:56 +08:00
43 lines
963 B
ReStructuredText
43 lines
963 B
ReStructuredText
OpenTelemetry FastAPI Instrumentation
|
|
=======================================
|
|
|
|
|pypi|
|
|
|
|
.. |pypi| image:: https://badge.fury.io/py/opentelemetry-instrumentation-fastapi.svg
|
|
:target: https://pypi.org/project/opentelemetry-instrumentation-fastapi/
|
|
|
|
|
|
This library provides automatic and manual instrumentation of FastAPI web frameworks,
|
|
instrumenting http requests served by applications utilizing the framework.
|
|
|
|
auto-instrumentation using the opentelemetry-instrumentation package is also supported.
|
|
|
|
Installation
|
|
------------
|
|
|
|
::
|
|
|
|
pip install opentelemetry-instrumentation-fastapi
|
|
|
|
|
|
Usage
|
|
-----
|
|
|
|
.. code-block:: python
|
|
|
|
import fastapi
|
|
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
|
|
|
|
app = fastapi.FastAPI()
|
|
|
|
@app.get("/foobar")
|
|
async def foobar():
|
|
return {"message": "hello world"}
|
|
|
|
FastAPIInstrumentor.instrument_app(app)
|
|
|
|
|
|
References
|
|
----------
|
|
|
|
* `OpenTelemetry Project <https://opentelemetry.io/>`_ |