Extend current prefect with Opentelemetry capability to monitor
Project description
prefect-opentelemetry
Welcome!
Extend prefect Orion with Opentelemetry capability to monitor the server side
Getting Started
This project create a new Perfect orion factory that wrap the original one and add opentelemetry capability for the following area
- FastAPI
- SQLAlchemy
- Postgres
- SQLLite
This is setup to only export all the opentelemetry at the format OTLP to an exporter that you can use after to dispatch to your metrics, log or trace.
Run Sample
The project has a docker compose file that allow you to start a server with PostgreSQL which will push the trace to Zipkin. The sample is using OpenTelemetry-Collector as a buffer. This allow you to push your trace to any standard trace like zipkin, jeager or tempo Sample view from zipkin
Python setup
Requires an installation of Python 3.8+ .
We recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.
These tasks are designed to work with Prefect 2.0. For more information about how to use Prefect, please refer to the Prefect documentation.
Note Because this change the base factory that create FastAPI app, you cannot use
prefect orion start
Start Prefect server using manual command of uvicorn
uvicorn --app-dir $(python -c 'import prefect; print(prefect.__module_path__.parent)') --factory prefect_opentelemetry.server:create_app_with_OTLP --host 0.0.0.0 --port 4200
The part $(python -c 'import prefect; print(prefect.__module_path__.parent)')
allow to setup the app-dir to ensure the UI can work.
The setup of the server is done using env var. You can find the list from prefect here. The import one to setup are
- PREFECT_ORION_DATABASE_CONNECTION_URL: Coonection string to the database
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: URL to the OTLP colletor using gRPC
- PREFECT_ORION_SERVICES_SCHEDULER_ENABLED: To only enable the scheduler
- PREFECT_ORION_ANALYTICS_ENABLED: To enable Analytic
- PREFECT_ORION_SERVICES_LATE_RUNS_ENABLED: To enable late run
- PREFECT_ORION_SERVICES_UI: To enable the UI
Resources
If you encounter any bugs while using prefect-opentelemetry
, feel free to open an issue in the prefect-opentelemetry repository.
If you have any questions or issues while using prefect-opentelemetry
, you can find help in either the Prefect Discourse forum or the Prefect Slack community.
Development
If you'd like to install a version of prefect-opentelemetry
for development, clone the repository and perform an editable install with pip
:
git clone https://github.com/davzucky/prefect-opentelemetry.git
cd prefect-opentelemetry/
pip install -e ".[dev]"
# Install linting pre-commit hooks
pre-commit install
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
File details
Details for the file prefect-opentelemetry-0.1.0.tar.gz
.
File metadata
- Download URL: prefect-opentelemetry-0.1.0.tar.gz
- Upload date:
- Size: 31.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b12b0e77e48bc46f6263f831be3ad075d30ebb7ecdc8970fd56594cdcc0ebdd |
|
MD5 | 5026799d6120246d9351a25586542475 |
|
BLAKE2b-256 | 3c37c00fe05762747a9c26ff425bc5964a3c35a59a6bcf0144ae855deaf5a2d5 |
File details
Details for the file prefect_opentelemetry-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: prefect_opentelemetry-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b392d4a28c1428f989f1a3522d4fcd7e88ad55e41d9668b9d543f2558e3e773 |
|
MD5 | 32a03eee6489525c98d23f6997faee19 |
|
BLAKE2b-256 | a92fbe2c9e9d0b7c295cd26d2e9cd2ecaf3ecb7f00cd28a3010264791212d4b7 |