otel-metry
Zero-config OpenTelemetry auto-instrumentation for Flask apps. One init() call and your app exports traces and metrics to CubeAPM (or any OTLP-compatible backend).
Installation
pip install otel-metry
With optional instrumentors:
pip install otel-metry[all] # requests, sqlalchemy, redis, psycopg2, celery
pip install otel-metry[requests] # just requests
Quick Start
import otelmetry
otelmetry.init(endpoint="http://cubeapm:4317", service_name="my-app")
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World"
That's it. All Flask requests, database queries, and outgoing HTTP calls are traced automatically.
Configuration
Programmatic
otelmetry.init(
endpoint="http://cubeapm:4317",
service_name="my-app",
insecure=True,
resource_attributes={"deployment.environment": "production"},
)
Environment Variables
| Variable | Fallback | Default |
|---|---|---|
OTEL_METRY_ENDPOINT |
OTEL_EXPORTER_OTLP_ENDPOINT |
http://localhost:4317 |
OTEL_METRY_SERVICE_NAME |
OTEL_SERVICE_NAME |
unknown-service |
OTEL_METRY_INSECURE |
— | true |
OTEL_METRY_ENABLED |
— | true |
Zero-Code (env vars only)
export OTEL_METRY_ENDPOINT=http://cubeapm:4317
export OTEL_METRY_SERVICE_NAME=my-app
import otelmetry.auto # auto-initializes from env vars
from flask import Flask
app = Flask(__name__)
Auto-Instrumented Libraries
If installed, the following are instrumented automatically:
- Flask (always)
- requests — outgoing HTTP calls
- SQLAlchemy — database queries
- Redis — cache operations
- psycopg2 — PostgreSQL queries
- Celery — task queues
API
otelmetry.init(...) # Initialize (call once)
otelmetry.shutdown() # Flush and stop (called automatically on exit)
otelmetry.get_tracer(name) # Get a tracer for manual spans
otelmetry.get_meter(name) # Get a meter for custom metrics
With Gunicorn
# gunicorn.conf.py
def post_fork(server, worker):
import otelmetry
otelmetry.init(endpoint="http://cubeapm:4317", service_name="my-app")
Metadata
Release files for otel-metry 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| otel_metry-0.2.0.tar.gz | 6.0 kB | Without provenance | Details for otel_metry-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| otel_metry-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for otel_metry-0.2.0-py3-none-any.whl |
Total release size: 13.0 kB
Release files / otel_metry-0.2.0.tar.gz
| Download URL | otel_metry-0.2.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2332524ba5c81524831f122cfc91a602c255925f466ad6d565a16ef10bfb1cb0
|
|
BLAKE2b-256 checksum How to use checksums |
dfe238f9beff1c1df5dee672225ba91fbe9ae1e8387ef5e315ba72d0480b431a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / otel_metry-0.2.0-py3-none-any.whl
| Download URL | otel_metry-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
da9fc0fe97b1ed6cc3f408f1c5d1886a8fd73c466463d4a02236fd37d6d462be
|
|
BLAKE2b-256 checksum How to use checksums |
7652c936057cf9f408dd4f5391807e50dde3a5ca3e2b79d1c59900133330b7c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for otel-metry 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.