Skip to main content

Agent-agnostic event emission SDK for Quadrant Event Manager

Project description

Cerebricks Events SDK

Lightweight SDK to emit standardized events to the Event Manager API and compute health across common service targets.

Install (local)

pip install -e .

Or build wheels and install:

python -m build
pip install dist/*.whl

Environment variables:

  • EVENT_MANAGER_URL (default set in code)
  • CBX_HTTP_TIMEOUT_S (default 10)
  • CBX_RETRIES (default 2)

Usage

from cerebricks_events import (
  post_start, post_status_change, post_health, post_error, post_heartbeat,
  compute_health, DEFAULT_TARGETS
)

# Extract headers from request
agent_id = headers.get("agent_id")
session_id = headers.get("session_id")
initiated_by = headers.get("initiatedby")
authtoken = headers.get("authorization")

# Start
post_start(agent_id, session_id, initiated_by, authtoken)

# Heartbeat
post_heartbeat(agent_id, session_id, initiated_by, authtoken,
               status="alive", active_task="My stage2", previous_task="My stage1", nexttaskdelay=10)

# Health
score, condition, unhealthy = compute_health(DEFAULT_TARGETS)
post_health(agent_id, session_id, initiated_by, authtoken, score, condition, unhealthy)

# Status change
post_status_change(agent_id, session_id, initiated_by, authtoken, new_status="Completed", status_message="Done")

# Error
post_error(agent_id, session_id, initiated_by, authtoken, "E001", "Test error")

Health computation

compute_health(targets) probes each URL via HEAD/OPTIONS/GET (any <500 is success; JSON with {status: ok|healthy|pass} counts as ok). Returns (health_score:int, condition:str, unhealthy:list).

License

MIT

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

cerebricks_events-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

cerebricks_events-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cerebricks_events-0.1.0.tar.gz
Algorithm Hash digest
SHA256 65e030689e593eaf241fe97d433d5cf43206b91508621a575ed2616566569705
MD5 f86fee2e35fcf629b5f265516fe81513
BLAKE2b-256 4ae5d800cfc3029e2731547e0e37d9ecc8dd59a84c7add360fd718dffbfb86bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cerebricks_events-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f67f767072cde699e7a3d907a1914c0f4553b41688a71bf673c71fdab039ef01
MD5 03c31a06b4e82806b0b23100d17d638d
BLAKE2b-256 dae186b64102598655d15d2c256249b3cc8c36ef58fbd674ceae2211a3e6fd7f

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