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 https://metrixwire.com/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="https://metrixwire.com/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 1.3.1

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 1.3.1
File Size Uploaded Provenance Actions
metrixwire-1.3.1.tar.gz 17.7 kB Without provenance Details for metrixwire-1.3.1.tar.gz

Built distribution (wheel)

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

Total release size: 46.8 kB

Release files / metrixwire-1.3.1.tar.gz

Download URL metrixwire-1.3.1.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6edeea9fa7ca86141a38ce65a1387fbace0b6be00f448fd4018b91335dedccbb
BLAKE2b-256 checksum
How to use checksums
fd650588a9536478e9a00368f8cb8e12c96befee45cc902d504aea158816f97d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

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

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

Security for metrixwire 1.3.1

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