Skip to main content

metrixwire (Python)

Zero-config APM SDK for Python. Call init() once — every request, database query, cache op and outbound HTTP call is instrumented automatically. There is no manual span API and no middleware to wire up. Non-blocking: if the MetrixWire endpoint is down, your app keeps running normally.

Installation

pip install metrixwire

Zero required dependencies — the core uses only the standard library.

Usage

import metrixwire

metrixwire.init(api_key="mw_...")

That's it. Do this once, as early as possible in your process (before your server starts). Every HTTP request becomes a trace, and every query / HTTP call / cache op within it becomes a span.

Auto-init as early as possible

Import and init at the very top of your entry module (or a sitecustomize.py on your PYTHONPATH) so the patches are installed before your framework and drivers are used:

# sitecustomize.py — or the first lines of your app's entry point
import metrixwire
metrixwire.init()  # reads METRIXWIRE_KEY / METRIXWIRE_ENDPOINT / METRIXWIRE_ENABLED from env

With no arguments, init() reads its config from the environment:

Env var Purpose
METRIXWIRE_KEY Project API key (required to enable)
METRIXWIRE_ENDPOINT Ingest URL — base or full /ingest (default http://localhost:3000/ingest)
METRIXWIRE_ENABLED false to disable entirely

A missing API key runs the SDK disabled — it never raises.

How the automatic tracing works

A trace is opened for every incoming request by patching each framework's single entry point — no middleware, no per-route setup:

Framework Traced automatically How
Flask ✅ wraps Flask.wsgi_app; route from the matched URL rule (/users/<id>)
Django ✅ patches WSGIHandler.__call__ and ASGIHandler.__call__; route from the resolver match
FastAPI · Starlette ✅ wraps Starlette.__call__ (ASGI); route from the matched pattern (/users/{id})
Bare / other WSGI (wsgiref, …) ✅ wrap once with metrixwire.wsgi.MetrixWireMiddleware

For a bare or unsupported WSGI app:

from metrixwire.wsgi import MetrixWireMiddleware
app = MetrixWireMiddleware(app)

Each trace records the route, HTTP status, response byte size (for the large-response detector), memory growth (for the memory-spike detector), and any unhandled exception.

Automatically instrumented libraries

Installed via init() — each is best-effort: if the library isn't importable it's skipped silently.

Library Span How
psycopg2 db_query (rowCount) patches psycopg2.extensions.cursor.execute/executemany
psycopg (v3) db_query (rowCount) patches psycopg.Cursor.execute/executemany
sqlite3 db_query (rowCount) patches sqlite3.Cursor.execute/executemany
PyMySQL · mysqlclient db_query (rowCount) patches the driver's Cursor.execute/executemany
Django ORM · SQLAlchemy db_query automatic — they run on the drivers above
requests http_call (statusCode) patches Session.request
stdlib http.client / urllib http_call (statusCode) patches HTTPConnection.request/getresponse
redis-py cache (custom, kind=cache) patches Redis.execute_command (records hit/miss)
DB transactions custom (kind=transaction) times BEGIN…COMMIT / connection.commit()

Database spans also capture a sourceLocation (file.py:42) pointing at the nearest application frame.

init options

metrixwire.init(
    api_key="mw_...",                        # required (or METRIXWIRE_KEY)
    endpoint="http://localhost:3000/ingest",  # default; base URL is accepted too
    flush_interval_ms=5000,                   # how often batches are sent
    enabled=True,                             # set False to disable entirely
    timeout_ms=3000,                          # send timeout (short, non-blocking)
    max_batch=20,                             # flush immediately once this many are queued
    capture_source=True,                      # capture the file:line a span originated from
)

Escape hatch

Requests, queries, HTTP calls and cache ops are all captured automatically. The one manual helper — for frameworks that catch their own errors before the SDK sees them — is:

import metrixwire

try:
    ...
except Exception as e:
    metrixwire.capture_exception(e)   # attach it to the active trace
    raise

Non-blocking behavior

  • Traces are batched and sent off the request path on a background daemon thread with a short timeout.
  • All transport errors are swallowed — instrumentation never throws into your app.
  • A final flush runs at process exit (atexit); you can also call metrixwire.flush() before a short-lived process exits.

Metadata

Release files for metrixwire 0.2.4

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

Source distribution (sdist)

Source distribution for metrixwire 0.2.4
File Size Uploaded Provenance Actions
metrixwire-0.2.4.tar.gz 17.4 kB Without provenance Details for metrixwire-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for metrixwire 0.2.4
File Interpreter ABI Platform Actions
metrixwire-0.2.4-py3-none-any.whl Python 3 none any Details for metrixwire-0.2.4-py3-none-any.whl

Total release size: 46.5 kB

Release files / metrixwire-0.2.4.tar.gz

Download URL metrixwire-0.2.4.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7637433334c359f88fe013ee4c74957f76f328590ea7499ccdf446a495de0c29
BLAKE2b-256 checksum
How to use checksums
264ef6a292eb63fe9aff25d20cf819fb7251f69e1acd364754bbd472d9d5a01c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / metrixwire-0.2.4-py3-none-any.whl

Download URL metrixwire-0.2.4-py3-none-any.whl
Size 29.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92b1684adb3c6a0ca9536cae3397d52d0167b8d4c86a3f6d041e1ffb949ea836
BLAKE2b-256 checksum
How to use checksums
f80f43ca73a4e1197bf932d3198deb9793f81710bf3c562a051a752122fedd31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for metrixwire 0.2.4

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