Skip to main content

AIOps Platform SDK — exception capture, heartbeat, and Flask integration

Project description

AIOps SDK

Python SDK for the AIOps Platform — automatic exception capture, heartbeat monitoring, and Flask integration.

Installation

pip install aiops-sdk             # core only
pip install "aiops-sdk[flask]"    # with Flask integration

Quick Start

import aiops_sdk
from aiops_sdk.integrations.flask import init_flask

# Initialise once at startup (reads AIOPS_API_KEY from env if not passed)
aiops_sdk.init(api_key="your-api-key")

# Register Flask integration (call after your Flask app is created)
init_flask(app)

That's it. The SDK will automatically:

  • Report unhandled exceptions before the process exits
  • Capture every HTTP 4xx/5xx error response (extracts the real error from your JSON response body)
  • Forward ERROR and CRITICAL log records as incidents
  • Send heartbeats every 30 seconds so the platform knows the service is alive

Environment Variables

Variable Required Default Description
AIOPS_API_KEY Yes Platform API key
AIOPS_SERVICE_NAME No unknown-service Service name shown in incidents
AIOPS_ENV No production Environment (production / staging / etc.)
AIOPS_PLATFORM_URL No https://aiops.1genimpact.cloud Override if self-hosting the platform
AIOPS_SERVICE_BASE_URL No auto-detected This service's own base URL (used for automated fix callbacks)
AIOPS_SKIP_PATHS No Extra paths to exclude from monitoring (comma-separated, e.g. /admin/health,/internal/ping)

What Gets Captured

Source Mechanism Notes
Unhandled exceptions sys.excepthook replacement Blocks until delivered (sync send)
Flask exceptions got_request_exception signal Full stack trace preserved
HTTP 4xx/5xx responses after_request hook Extracts real error from jsonify body
ERROR / CRITICAL logs Root logging handler Stack trace from exc_info when available

What's Excluded (Built-in Noise Filtering)

The SDK is designed for zero false positives in production:

  • OPTIONS and HEAD requests — CORS preflights and HTTP HEAD probes are never application errors
  • Health-check paths/health, /healthz, /ping, /ready, /alive, /readiness, /liveness, /metrics, /status, /favicon.ico, /robots.txt
  • Static files.js, .css, .ico, .png, .jpg, .svg, .woff, .woff2, .ttf, .map, and more
  • HTTP 404 — "path not found" is expected client behaviour, not a server bug
  • HTTP 429 — rate-limiting is working as intended, not an error state
  • Werkzeug access log noise — bot/scanner traffic logged by the HTTP server layer
  • urllib3 / requests library errors — connection pool noise when the platform itself is temporarily unreachable
  • SDK's own logs — prevents feedback loops if the background worker logs a failure

Adding Custom Exclusions

# Exclude additional paths without code changes:
export AIOPS_SKIP_PATHS=/admin/health,/internal/ping,/ops/ready

How It Works

Flask request
    │
    ├─► got_request_exception  ──► capture_exception()  ──► send_async() ──► queue
    │         (real exceptions, full stack trace)
    │
    └─► after_request hook
            │
            ├─ [noise filter] OPTIONS / HEAD → skip
            ├─ [noise filter] /health → skip
            ├─ [noise filter] .js/.css → skip
            ├─ [dedup guard] already captured by signal → skip
            │
            └─ status in {400,401,403,500,502,503,504}
                   │
                   ├─ extract real error from jsonify({message/error/detail})
                   ├─ infer error type (AttributeError, KeyError, DatabaseError, …)
                   └─► send_async() ──► queue

Background worker (daemon thread)
    └─ drains queue → POST /v1/sdk/exception (retry 3×, backoff 1s/2s)

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

aiops_sdk-0.1.6.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

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

aiops_sdk-0.1.6-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file aiops_sdk-0.1.6.tar.gz.

File metadata

  • Download URL: aiops_sdk-0.1.6.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for aiops_sdk-0.1.6.tar.gz
Algorithm Hash digest
SHA256 f427ca984eaaa0a5730ccf4bd840cb54a3c2c94ca243b7bf2b9591a38974224c
MD5 2435ff1d0b56cecd967bfc8cdde340f2
BLAKE2b-256 847f68849ee0618c544c2c6de28892a2b043c058ba203334078478e4b392d796

See more details on using hashes here.

File details

Details for the file aiops_sdk-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: aiops_sdk-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for aiops_sdk-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ba92d95e7176c706c4bce3f9f3ecf150ccdf84a148487690bf24344563aa62bb
MD5 a0880d336737d86e3689ec45ad8aa435
BLAKE2b-256 d5b4b56a3c16eab2c9ee8d1eaa753179fbc8cdf60274756ac9f472ad2b54ea1a

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