Skip to main content

ExeWatch Python SDK

Lightweight APM / observability SDK for Python applications.
Zero external dependencies — uses only the Python 3.7+ standard library.

Installation

pip install exewatch-sdk

Python 3.7 or later. In a project with a virtual environment, activate it first. To update: pip install --upgrade exewatch-sdk. The package is on PyPI and you import it as exewatch:

from exewatch import initialize_exewatch, ew, finalize_exewatch

Quick Start

from exewatch import initialize_exewatch, ew, finalize_exewatch

# Initialize (once at startup)
initialize_exewatch("ew_win_YOUR_API_KEY", "your-customer-id", app_version="1.0.0")

# Log
ew.info("Application started", "startup")
ew.warning("Disk space low", "system")

# Shutdown (at exit — also registered via atexit)
finalize_exewatch()

Features

Logging (5 levels)

ew.debug("verbose details", "module")
ew.info("normal operation", "module")
ew.warning("something unusual", "module")
ew.error("something failed", "module")       # includes breadcrumbs + stack trace
ew.fatal("critical failure", "module")        # includes breadcrumbs + stack trace

Extra data via keyword arguments:

ew.info("Order placed", "orders", order_id="12345", total=99.99)

Exception Capture

try:
    risky_operation()
except Exception as e:
    ew.error_with_exception(e, "module", "Context message")

Unhandled exceptions

Once initialized, the SDK reports an exception that nothing catches (in the main thread or, on Python 3.8+, in another thread) as a fatal log tagged exception, with the stack trace, and sends it before the process ends. The previous sys.excepthook still runs, so the traceback is printed as usual. KeyboardInterrupt (Ctrl+C) is not reported.

At startup

initialize_exewatch logs Application started (tag exewatch) and sends the hardware info of the device (memory, CPU, disks, monitors, network, locale), like the Delphi SDK.

Timing / Profiling

ew.start_timing("db_query", "database")
result = db.execute("SELECT ...")
elapsed = ew.end_timing("db_query")  # returns ms, logs automatically

# Stack-based (LIFO)
ew.start_timing("outer")
ew.start_timing("inner")
ew.end_timing()  # ends "inner"
ew.end_timing()  # ends "outer"

# With success/failure
elapsed = ew.end_timing("op", success=False)

# Cancel without logging
ew.cancel_timing("op")

Breadcrumbs

Automatically attached to ERROR/FATAL logs.

from exewatch import BreadcrumbType

ew.add_breadcrumb(BreadcrumbType.NAVIGATION, "nav", "Opened settings")
ew.add_breadcrumb(BreadcrumbType.CLICK, "ui", "Clicked Save")
ew.add_breadcrumb(BreadcrumbType.QUERY, "db", "SELECT * FROM users")
# Next error() or fatal() will include these breadcrumbs

Metrics

# Counters (cumulative)
ew.increment_counter("orders.placed", 1.0, "shop")
ew.increment_counter("revenue", 49.99, "billing")

# Gauges (instantaneous)
ew.record_gauge("memory_mb", 256.0, "system")
ew.record_gauge("queue_size", 42.0, "worker")

# Periodic gauge (sampled automatically in background)
def get_memory():
    import resource
    return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024.0

ew.register_periodic_gauge("memory_mb", get_memory, "system")

User Identity

ew.set_user("user-42", "jane@example.com", "Jane Doe")
# All subsequent logs include user info
ew.info("User action")

ew.clear_user()

Global Tags

ew.set_tag("environment", "production")
ew.set_tag("feature_flag", "new_checkout")
# All subsequent logs include tag_environment, tag_feature_flag

ew.remove_tag("feature_flag")
ew.clear_tags()

Device Info

# Send hardware info (CPU, memory, disks, OS, etc.)
ew.send_device_info()

# Custom device metadata
ew.set_custom_device_info("license_type", "enterprise")
ew.set_custom_device_info("deployment", "on-premise")
ew.send_custom_device_info()

Runtime Configuration

# Change customer ID at runtime
ew.set_customer_id("new-customer")

# Enable/disable
ew.enabled = False  # suspend all logging
ew.enabled = True   # resume

Configuration Options

initialize_exewatch(
    api_key="ew_win_...",           # Required: your API key
    customer_id="acme-corp",         # Required: customer identifier
    app_version="1.0.0",            # Optional: application version
    endpoint="https://exewatch.com", # API endpoint
    storage_path="",                 # Custom storage path (default: platform-specific)
    buffer_size=100,                 # Events before auto-persist
    flush_interval_ms=5000,          # Persist interval (ms)
    retry_interval_ms=30000,         # Retry interval on failure (ms)
    sample_rate=1.0,                 # 0.0-1.0 (errors/fatals always sent)
    gauge_sampling_interval_sec=30,  # Periodic gauge interval
    max_pending_age_days=7,          # Auto-cleanup old files
    anonymize_device_id=False,       # GDPR: hash username in device ID
)

Architecture

  • Single file (exewatch.py): no package installation needed
  • File queue: logs persisted to disk before sending (crash-safe)
  • Background shipper thread: sends queued files to server
  • Background sampler thread: samples registered periodic gauges
  • Thread-safe: all shared state protected with locks
  • Thread-local breadcrumbs: each thread has its own trail

Platform Support

Feature Windows Linux
Logging Yes Yes
CPU info Registry /proc/cpuinfo
Memory info GlobalMemoryStatusEx /proc/meminfo
Disk info Win32 API /proc/mounts + statvfs
Monitor info EnumDisplayMonitors N/A
Boot time GetTickCount64 /proc/stat btime

Requirements

  • Python 3.7+
  • No external dependencies

Running Tests

pip install pytest
cd SDK/Python
pytest tests/ -v

Metadata

Release files for exewatch-sdk 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for exewatch-sdk 0.3.0
File Size Uploaded Provenance Actions
exewatch_sdk-0.3.0.tar.gz 24.2 kB Without provenance Details for exewatch_sdk-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for exewatch-sdk 0.3.0
File Interpreter ABI Platform Actions
exewatch_sdk-0.3.0-py3-none-any.whl Python 3 none any Details for exewatch_sdk-0.3.0-py3-none-any.whl

Total release size: 46.0 kB

Release files / exewatch_sdk-0.3.0.tar.gz

Download URL exewatch_sdk-0.3.0.tar.gz
Size 24.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3937af1a0fe13b7cfd89ae3e3e8c5169685517f642016976fb6fadd3d818caaa
BLAKE2b-256 checksum
How to use checksums
b5b116d485098858d3751730404bcb06b1cbbe696a8c23de7f8b3b5759052bd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / exewatch_sdk-0.3.0-py3-none-any.whl

Download URL exewatch_sdk-0.3.0-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eed64643268121e7dcf8066d6cd965be0d74215bb8323cbeeb567d202fcbec6f
BLAKE2b-256 checksum
How to use checksums
f40e8761b292806ba0712a75dd9c46f456fe9bc29af4b744ace90768519612ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for exewatch-sdk 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page