Skip to content

Latest commit

 

History

History
53 lines (36 loc) · 943 Bytes

File metadata and controls

53 lines (36 loc) · 943 Bytes

postDash Python SDK

Python client for sending events to an postDash server.

Install

pip install ./sdks/python

Usage

from postDash import Client

er = Client("http://localhost:6060/events", "myapp")

er.emit("deploy", {"env": "prod"})
er.error("crash", {"msg": "something broke"})
er.warn("high_latency", {"p99": 450})
er.debug("cache_miss")

er.flush()  # wait for pending events before exit

Channels

deploy = er.with_channel("deploy")
deploy.emit("started", {"branch": "main"})

Timed Operations

with er.timed("db_query") as t:
    result = do_query()
    t.data["rows"] = len(result)

No-Op Mode

When the URL is empty, all operations silently no-op:

import os
er = Client(os.environ.get("POSTDASH_URL", ""), "myapp")
er.emit("startup")  # safe even if POSTDASH_URL is unset

Requirements

Python 3.10+