Skip to main content

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

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

Metadata

Release files for prefect-opentelemetry 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prefect-opentelemetry 0.1.0
File Size Uploaded
prefect-opentelemetry-0.1.0.tar.gz 31.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prefect-opentelemetry 0.1.0
File Interpreter ABI Platform
prefect_opentelemetry-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 45.2 kB

Release files / prefect-opentelemetry-0.1.0.tar.gz

Download URL prefect-opentelemetry-0.1.0.tar.gz
Size 31.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6b12b0e77e48bc46f6263f831be3ad075d30ebb7ecdc8970fd56594cdcc0ebdd
BLAKE2b-256 checksum
How to use checksums
3c37c00fe05762747a9c26ff425bc5964a3c35a59a6bcf0144ae855deaf5a2d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Release files / prefect_opentelemetry-0.1.0-py3-none-any.whl

Download URL prefect_opentelemetry-0.1.0-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b392d4a28c1428f989f1a3522d4fcd7e88ad55e41d9668b9d543f2558e3e773
BLAKE2b-256 checksum
How to use checksums
a92fbe2c9e9d0b7c295cd26d2e9cd2ecaf3ecb7f00cd28a3010264791212d4b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page