Skip to main content

Python SDK for Vestara crash reporting and remote logging.

Project description

Vestara Python SDK

Server-side Python SDK for Vestara crash reporting and remote logging.

Requires Python 3.8+ — zero external runtime dependencies.

Installation

pip install vestara

Quick Start

import vestara

vestara.init(
    token="YOUR_SDK_TOKEN",
    environment="production",
    app_version="1.0.0",
    target_category="python_worker",
    service_name="Python Worker",
    app_identifier="python-worker",
)

vestara.log("info", "Server started", {"port": 3000})

Default endpoint: https://api.vestara.dev. No api_url needed for normal Vestara SaaS usage.

Runtime target metadata

You can provide metadata to identify this application in the dashboard:

  • target_category: The kind of target (e.g., python_worker).
  • service_name: Human-readable name (e.g., Python Worker).
  • app_identifier: Technical identifier (e.g., python-worker).

API

vestara.init(options)

Initializes the SDK. Must be called before any other API.

vestara.init(
    token="YOUR_SDK_TOKEN",
    environment="production",  # production | staging | development
    app_version="1.0.0",
    target_category="python_worker",
    service_name="Python Worker",
    app_identifier="python-worker",
    before_send=None,  # optional callback
)

before_send hook

The before_send option lets you inspect, modify, or drop events before they are queued:

def redact_sensitive(event):
    # Redact sensitive fields
    if "password" in event.get("payload", {}).get("data", {}):
        event = dict(event)
        event["payload"] = dict(event["payload"])
        event["payload"]["data"] = dict(event["payload"]["data"])
        event["payload"]["data"]["password"] = "[REDACTED]"
        return event
    
    # Drop noisy health checks
    if event.get("payload", {}).get("message") == "health-check":
        return None
    
    return event

vestara.init(
    token="YOUR_SDK_TOKEN",
    before_send=redact_sensitive,
)

Behavior:

  • Return a modified event dict to send the modified version
  • Return None to drop the event
  • If the hook raises an exception, the original event is sent (fail-open)

Note: The Vestara backend also applies server-side redaction as a safety layer.

Optional api_url for local development, staging, or self-hosted:

vestara.init(
    token="YOUR_SDK_TOKEN",
    api_url="http://localhost:3000",
    environment="development",
)

vestara.log(level, message, data?)

Sends a log event.

vestara.log("info", "Request processed", {"request_id": "123"})
vestara.log("warn", "Slow query detected", {"duration": 2000})
vestara.log("error", "Database connection failed", {"host": "db.example.com"})

Supported levels: debug, info, warn, error, fatal.

vestara.capture_exception(error, context?)

Captures a Python exception.

try:
    result = process_data()
except Exception as e:
    vestara.capture_exception(e, {"operation": "process_data"})

vestara.set_user(context)

Associates a user with future events.

vestara.set_user({"id": "user-123", "email": "user@example.com"})

What is Automatically Captured

  • Uncaught exceptions: sys.excepthook captures unhandled exceptions. The original hook is called after capture.
  • Thread exceptions: threading.excepthook captures uncaught exceptions in threads. The original hook is called after capture.
  • Graceful shutdown: Remaining events are flushed on process exit via atexit.
  • Periodic flush: Events are sent every 10 seconds in a background daemon thread.

What is NOT Supported in V1

  • Async/await exceptions: Only synchronous thread exceptions are captured automatically.
  • Django/FastAPI/Flask integration: Not built-in. Wrap your exception handlers or call vestara.capture_exception() manually.
  • Structured logging frameworks: Not auto-instrumented.
  • Distributed tracing / APM: Not implemented.
  • Guaranteed persistence: Queue is in-memory only. SIGKILL or sudden process termination will lose queued events.
  • File-backed queue: Not implemented.

Offline Queue

Events are queued in memory (not persisted to disk).

  • Max 500 events
  • Logs dropped (not crashes) when queue is full
  • Crash events evict the oldest log when queue is full
  • Events are sent in batches of up to 50 every 10 seconds
  • Crash events are sent immediately
  • Remaining events are flushed on atexit (best-effort, may not complete on SIGKILL)

Device Settings

The SDK polls /v1/sdk/device-settings every 60 seconds. If logging_enabled is false, log events are suppressed. Crash events are always sent regardless of this setting.

SDK Token

Find your SDK token in the Vestara dashboard under Settings → SDK & Token.

The SDK token is write-only — it can only ingest events. It cannot read your data.

License

This SDK is licensed under the Apache License 2.0.

Copyright 2026 Ahsan Iqbal.

Vestara, the Vestara name, logos, domain, and related branding are not granted under this license.

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

vestara-0.1.1.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

vestara-0.1.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file vestara-0.1.1.tar.gz.

File metadata

  • Download URL: vestara-0.1.1.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for vestara-0.1.1.tar.gz
Algorithm Hash digest
SHA256 11f850281a77355238be4e89cd09e38549367f8d7cc3c8caff98faf0373aabeb
MD5 4d756a95d2dce5233c39df81d2536160
BLAKE2b-256 a214f28e0358ca36fc47b1194878618a972e9b385bbb20d73184a2114d464fe3

See more details on using hashes here.

File details

Details for the file vestara-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: vestara-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for vestara-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c177f125a13a067581f78c702129bff31339a2551b85f6d679f5c3eada5cd1b
MD5 68e9d821a64d4008746e951ff46811ce
BLAKE2b-256 837d9b85552897947d6c871674f9c8ea7ea33e9ffcf3916d51c0627eb4620082

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