Skip to main content

SentienGuard APM SDK for Python — auto-instruments your app via OpenTelemetry

Project description

@sentienguard/apm — Python SDK

Minimal, production-safe APM SDK for Python applications. Powered by OpenTelemetry with zero manual instrumentation.

Installation

# Pick the extras for your stack
pip install sentienguard-apm[flask]
pip install sentienguard-apm[django]
pip install sentienguard-apm[fastapi]

# Or install everything
pip install sentienguard-apm[all]

Quick Start

# 1. Import the SDK (before your app code)
import sentienguard_apm

# 2. Your app — that's it, no other changes needed
from flask import Flask
app = Flask(__name__)

@app.route("/users/<int:id>")
def get_user(id):
    return {"id": id}

Set environment variables:

SENTIENGUARD_APM_KEY=your-app-key
SENTIENGUARD_SERVICE=my-api

The SDK automatically instruments your application and sends metrics to SentienGuard.

Configuration

All configuration is via environment variables (same as the Node.js SDK):

Variable Required Default Description
SENTIENGUARD_APM_KEY Yes Your application's APM key
SENTIENGUARD_SERVICE Yes Service name (e.g., orders-api)
SENTIENGUARD_ENV No production Environment name
SENTIENGUARD_ENDPOINT No https://sentienguard-dev.the-algo.com/api/v1/apm/ingest Backend URL
SENTIENGUARD_FLUSH_INTERVAL No 10 Flush interval in seconds
SENTIENGUARD_DEBUG No false Enable debug logging

Note: If SENTIENGUARD_APM_KEY or SENTIENGUARD_SERVICE is missing, the SDK disables itself silently.

What Gets Tracked

  • HTTP Requests — Incoming requests with method, route, status, and latency
  • Dependencies — Outgoing HTTP calls to external services
  • Databases — MongoDB, PostgreSQL, MySQL, Redis, SQLAlchemy queries
  • Errors — Unhandled exceptions

Framework Examples

Flask

pip install sentienguard-apm[flask]
import sentienguard_apm
from flask import Flask

app = Flask(__name__)

@app.route("/api/orders/<int:id>")
def get_order(id):
    return {"id": id}

Django

pip install sentienguard-apm[django]
# settings.py — no middleware needed, auto-instrumented
# Just ensure sentienguard_apm is imported early

# wsgi.py or manage.py
import sentienguard_apm  # add this line at the top

FastAPI

pip install sentienguard-apm[fastapi]
import sentienguard_apm
from fastapi import FastAPI

app = FastAPI()

@app.get("/api/users/{user_id}")
async def get_user(user_id: int):
    return {"id": user_id}

Late Initialization (dotenv)

If you load environment variables after import (e.g., with python-dotenv):

from dotenv import load_dotenv
load_dotenv()

import sentienguard_apm
sentienguard_apm.initialize(force=True)

API Reference

import sentienguard_apm

sentienguard_apm.initialize(force=True)  # Re-init after env change
sentienguard_apm.shutdown()              # Graceful shutdown (flushes pending data)

Auto-Instrumented Libraries

The SDK auto-detects and instruments these libraries if installed:

Library Install extra What's tracked
Flask [flask] Incoming requests
Django [django] Incoming requests
FastAPI [fastapi] Incoming requests
requests [requests] Outgoing HTTP
httpx [httpx] Outgoing HTTP (sync + async)
aiohttp [aiohttp] Outgoing HTTP (async)
PyMongo [pymongo] MongoDB operations
psycopg2 [psycopg2] PostgreSQL queries
redis-py [redis] Redis commands
SQLAlchemy [sqlalchemy] SQL queries

Requirements

  • Python >= 3.8

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

sentienguard_apm-1.0.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

sentienguard_apm-1.0.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file sentienguard_apm-1.0.0.tar.gz.

File metadata

  • Download URL: sentienguard_apm-1.0.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for sentienguard_apm-1.0.0.tar.gz
Algorithm Hash digest
SHA256 00a4e3436e40c1f4ed1eb6abb3831ddc9c93d114b4a1cbda67c8f973810ec3d6
MD5 e74c203ec2c7db7d6151ae2ddc77d526
BLAKE2b-256 7694ac4f37c61008d24a17341804e543229466f160275e1b5e8f3e74230b7ac7

See more details on using hashes here.

File details

Details for the file sentienguard_apm-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sentienguard_apm-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26b40c9a3f967f540ba5a00be2bdc81961319bcfebe8874498fd3ff37261228c
MD5 ef016910fe7cacd100de1721edc8f442
BLAKE2b-256 49cf56a1be106312ca48afcc9b184ae769c8aedef0df36de344dadcfd52ba2e7

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