otelstarter (Python)
Business-aware domain events for OpenTelemetry. Part of otelstarter.
from otelstarter import observability
observability.event(
"payment.completed",
domain="payments",
operation="payment",
outcome="success",
entity_type="payment",
entity_id=payment.id,
)
Each call emits one OpenTelemetry log-based event: a log record whose event name is payment.completed, linked to the current trace. OpenTelemetry adds the trace and span IDs, service name and environment itself.
Install
pip install otelstarter
otelstarter init adds it for you, pinned to the version it was tested with.
It depends only on opentelemetry-api. Run your app with OpenTelemetry configured (for example via otelstarter run -- <your command>), or event() quietly does nothing.
Rules it enforces
- Business meaning, not payloads. Only the named fields above exist, with values that are short strings or ints. Anything else is left out with a warning.
<domain>.<action>names, in lowercase, such asorder.createdorpayment.authorization.failed. A name that breaks the rule is still recorded, and a warning is logged once.- Never breaks your app.
event()never raises. Internal errors are logged once as a warning. - One signal per event. No duplicate span event or log line, and no automatic metric, so
entity_idnever becomes a metric label.
Seeing events while you develop
Set OTELSTARTER_CONSOLE_EVENTS=true and each event also prints one line to stderr. otelstarter run -- <command> sets this for you.
[otelstarter] event order.created domain=orders outcome=success entity_id=ord_1 trace_id=e566aa670b7683784763c4860c4f6e71
This line is only printed, never exported, so the event is still sent once.
Problems such as a badly named event are logged as warnings on the otelstarter logger. They appear in your terminal next to your own logs, pointing at the line that called event(), and in your backend:
WARNING [otelstarter] [main.py:14] [trace_id=...] - Event name 'ordercreated' does not follow <domain>.<action> ...
To turn them off: logging.getLogger("otelstarter").setLevel(logging.ERROR).
Finding events in Grafana
With otelstarter run, open Grafana → Explore → Loki:
{service_name="shop"} |= "payment." # all payment events
{service_name="shop"} | event_domain="payments" # by domain
{service_name="shop"} | event_outcome="failure" # failures only
{service_name="shop"} | scope_name="otelstarter" | detected_level="warn" # event problems
Each event carries trace_id, so you can jump from it to the request's trace in Tempo. Loki does not store OpenTelemetry's event-name field, which is why the event name is also the log body.
See docs/DOMAIN_EVENTS.md for the event model.
Development
cd sdk/python
python -m venv .venv && . .venv/bin/activate
pip install -e '.[dev]'
pytest
ruff check . && ruff format --check .
mypy
Metadata
Release files for otelstarter 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 | |
|---|---|---|---|
| otelstarter-0.2.0.tar.gz | 11.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| otelstarter-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.4 kB
Release files / otelstarter-0.2.0.tar.gz
| Download URL | otelstarter-0.2.0.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0193ec964d5be8caa0930efd8100dd2cd2dbe51168b36d80cec5cd8093fbda39
|
|
BLAKE2b-256 checksum How to use checksums |
9d8d1ecb59cdc625c0b621acf276b784fa47dd7a5aa729f7f4047ca91e0b3daf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / otelstarter-0.2.0-py3-none-any.whl
| Download URL | otelstarter-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5464ada206cd1444f09c4afea86518951dc3c96aad9a38404097c78c5da844fa
|
|
BLAKE2b-256 checksum How to use checksums |
fe0f8ee80130f56ef183cd067a550e13ec07ce796617c506e1edbd5f72b2c261
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency log