Skip to main content

LevelOps Python SDK — SLI event ingestion

Project description

LevelOps Python SDK

Ingest SLI events into LevelOps from any Python application.

Installation

pip install levelops

Quickstart

from levelops import LevelOpsClient

client = LevelOpsClient(api_key="<tenant_key>", sli_id="<uuid>")
client.record(fields={"result": "ok", "latency_ms": 120})
client.flush()

Usage

Direct record

# Auto-generated event_id (UUID v4)
client.record(
    fields={"result": "ok", "latency_ms": 120},
    dimensions={"service": "api", "region": "eu"},
)

# Explicit event_id for idempotent retries
client.record(fields={"result": "ok"}, event_id="my-trace-id")

Context manager (auto latency measurement)

# event_id auto-generated
with client.measure(dimensions={"service": "api"}) as ctx:
    # ... business logic ...
    ctx.set_result("ok")  # or "error"

# Explicit event_id
with client.measure(dimensions={"service": "api"}, event_id="trace-id") as ctx:
    ctx.set_result("ok")

Configuration

Parameter Default Description
api_key Tenant API key (required)
sli_id Target SLI UUID (required)
base_url https://api.levelops.io API base URL
batch_size 100 Flush after N events
flush_interval 1.0 Flush every N seconds

Behaviour

  • event_id auto-generated (UUID v4) per record() and per measure() exit. Override via event_id= parameter for idempotent retries.
  • timestamp auto-set to UTC now if not provided.
  • Thread-safe internal buffer flushed in background thread.
  • Retries on HTTP 429 respecting Retry-After header (max 3 attempts, exponential backoff).
  • flush() registered via atexit automatically.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

levelops-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

levelops-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file levelops-0.1.0.tar.gz.

File metadata

  • Download URL: levelops-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for levelops-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d563a5d4ca4840d62d9e1c3c88e12aadae5fa910c04468d2916d9d7cd205d9a0
MD5 cfc65534acedb0ced40069c9b543adf9
BLAKE2b-256 d923d856b17fde388eebc1d1c816cff7fcc70aca7c4f41830ddb4edadbca4f0d

See more details on using hashes here.

File details

Details for the file levelops-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: levelops-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for levelops-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 159ff13924ac88366d9c7492b57d31f5f3fbfd7d5cca04b6d61439b9a1e2d92f
MD5 92fbe9409bb64f8f96bae3db48223435
BLAKE2b-256 7077cb9175f0d8b54f7415dd9a6790a7d5a6ac7d24d9976c9489c4dbe7e69099

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page