Skip to main content

Vigilon

License: ISC PyPI Python versions

Vigilon Python SDK

Official Python SDK for Vigilon.

Vigilon is application monitoring for SaaS applications, based on OpenTelemetry. Out of the box it provides RESTful service and endpoint health, error monitoring and alerting, end-to-end tracing, and background job monitoring.

The SDK sets up standard OpenTelemetry instrumentation for your app and exports it to Vigilon over OTLP, with no proprietary agent. One register() call, or the zero-code opentelemetry-instrument launcher, instruments FastAPI, Flask and Django, plus common HTTP and database clients.

Install

pip install vigilon

Requires Python 3.10 or later.

Quick start

Create an API key in the Vigilon dashboard under your project's Settings page, API Keys tab.

Then call register() as the first statement of your entrypoint, before application modules import the frameworks being instrumented:

import vigilon

vigilon.register(
    api_key="your-api-key",
    app_name="your-app-name",
    environment="production",
    app_version="1.2.3",  # optional, recommended for deploy tracking
)

from app import create_app  # import your app AFTER register()

app = create_app()

Optional environment variables:

  • VIGILON_OTEL_ENDPOINT — override the OTLP HTTP base endpoint (traces go to <endpoint>/v1/traces); useful for local collectors and tests.
  • VIGILON_EXCLUDED_URLS — extra excluded-URL regexes, comma-separated (see below).

The app name is what Vigilon shows as the app's Service, and the version is the release used for deploy tracking. They are exported as the OpenTelemetry service.name and service.version resource attributes.

Full product documentation is at vigilon.io/docs.

Renamed settings

The register() arguments service_name and service_version were renamed to app_name and app_version, and the VIGILON_SERVICE_NAME and VIGILON_SERVICE_VERSION environment variables to VIGILON_APP_NAME and VIGILON_APP_VERSION. The old names still work until 0.2.0, ranked just below their replacements, and Vigilon logs a warning on startup for each one that is set. The value sent to Vigilon is unchanged, so the app keeps its Service and error groups when you rename.

Zero-code bootstrap

If you cannot (or would rather not) touch the entrypoint, launch the app under opentelemetry-instrument — the SDK registers itself through OpenTelemetry's distro/configurator hooks, driven entirely by environment variables:

VIGILON_API_KEY=your-api-key \
VIGILON_APP_NAME=your-app-name \
VIGILON_ENVIRONMENT=production \
VIGILON_APP_VERSION=1.2.3 \
opentelemetry-instrument python app.py
Variable Meaning
VIGILON_API_KEY Required. Your Vigilon API key.
VIGILON_APP_NAME Required. App name, shown as the app's Service in Vigilon.
VIGILON_ENVIRONMENT Required. Deployment environment (production, staging, …).
VIGILON_APP_VERSION Recommended — enables deploy tracking; the SDK warns when missing.
VIGILON_OTEL_ENDPOINT Optional OTLP endpoint override.
VIGILON_EXCLUDED_URLS Optional extra excluded-URL regexes, comma-separated.

Notes:

  • Pre-fork servers (gunicorn, uWSGI, Celery prefork) must not use this path — the SDK would start before the fork and lose its exporter thread in the workers. Use the per-worker register() recipes below instead.
  • Django: export DJANGO_SETTINGS_MODULE in the environment (not inside manage.py) — it must be set before opentelemetry-instrument initializes, or Django is deliberately left uninstrumented.
  • If another OpenTelemetry distro package is installed in the same environment, pin ours explicitly with OTEL_PYTHON_DISTRO=vigilon OTEL_PYTHON_CONFIGURATOR=vigilon.
  • A later in-process register() call is safely ignored (one warning), so code that also runs outside opentelemetry-instrument keeps working.

Instrumented libraries

register() (and the zero-code path) instruments whichever of these are installed — no configuration needed:

  • Web frameworks: FastAPI, Flask, Django (Django only when DJANGO_SETTINGS_MODULE is set — instrumenting without resolvable settings would break apps that configure Django later)
  • HTTP clients: requests, httpx, urllib3, aiohttp
  • PostgreSQL: psycopg, psycopg2
  • MySQL: mysql-connector-python, PyMySQL, mysqlclient
  • Other datastores: Redis, PyMongo, SQLAlchemy (any driver, including async engines)
  • AWS: Lambda flush handling (see below)

MySQL through SQLAlchemy is traced at both layers (an engine span with the driver span nested inside); async MySQL drivers (aiomysql, asyncmy) are traced via the SQLAlchemy async engine only.

App objects created before register()

FastAPI and Flask are instrumented by swapping the framework's app class, so an app object built before register() ran (usually an import-order problem you can't fix, e.g. inside a framework CLI) is left untouched. The escape hatch is the per-app instrumentor — pass your excluded URLs, since the merged defaults don't apply on this path:

from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor

FastAPIInstrumentor.instrument_app(app, excluded_urls="/health$,/ready$,/favicon\\.ico$")

(Flask: FlaskInstrumentor().instrument_app(app, excluded_urls=...).)

Pre-fork servers (gunicorn, uWSGI, Celery)

The SDK's exporter runs a background thread that does not survive fork(). Call register() once per worker, in the worker-startup hook — not at master/module import time:

# gunicorn.conf.py
def post_fork(server, worker):
    import vigilon

    vigilon.register(api_key=..., app_name=..., environment=...)
# uWSGI (run with --enable-threads)
from uwsgidecorators import postfork


@postfork
def start_vigilon():
    import vigilon

    vigilon.register(api_key=..., app_name=..., environment=...)
# Celery worker
from celery.signals import worker_process_init


@worker_process_init.connect
def start_vigilon(**kwargs):
    import vigilon

    vigilon.register(api_key=..., app_name=..., environment=...)

Excluded URLs

Health checks (/health, /ready, /favicon.ico) are excluded from instrumentation by default. Add your own patterns for uncovered health endpoints or long-lived SSE routes that would otherwise dirty service-level metrics:

vigilon.register(
    ...,
    excluded_urls=["/internal/health$", "/events/stream$"],
)

Patterns are regexes matched against the full request URL and are merged with the defaults. Excluded routes produce no server span at all — they disappear from tracing and from request metrics, which is exactly what you want for SSE.

Recording errors

Unhandled exceptions are recorded automatically. For errors your code catches and converts into an error response itself — invisible to instrumentation — call record_error:

from vigilon import record_error


@app.get("/data")
async def get_data():
    try:
        return await load_data()
    except Exception as error:
        record_error(error)
        return JSONResponse({"message": "failed"}, status_code=500)

If there is no active span, record_error is a no-op.

Background jobs

Wrap one execution of a background job — a cron tick, a queue processor, an interval loop — in with_job_monitor to report it as a Job Run. Each run starts its own trace, so database queries and outgoing requests made inside the job are attached to that run instead of being orphaned:

from vigilon import with_job_monitor


@with_job_monitor(name="sync-users", schedule="0 3 * * *")
async def sync_users(): ...


# Or as a context manager for inline blocks:
with with_job_monitor(name="refresh-cache"):
    refresh_cache()

name is a required, stable identifier — never interpolate per-item values (sync-user-42 fragments one job into unbounded identities). schedule is an optional cron expression enabling last-run and stale-job detection. Sync and async functions are both supported; errors are recorded on the run and re-raised.

with_job_monitor must run after register() has started the SDK. If it runs earlier, the job itself still executes normally, but the run is not reported.

AWS Lambda

Vigilon detects the Lambda runtime via AWS_LAMBDA_FUNCTION_NAME and adds the AWS Lambda instrumentation automatically, which flushes traces at the end of each invocation. No extra configuration is needed.

Support

Contributing

Build, test, and release instructions are in CONTRIBUTING.md.

License

ISC

Metadata

Release files for vigilon 0.1.7

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

Source distribution (sdist)

Source distribution for vigilon 0.1.7
File Size Uploaded Provenance Actions
vigilon-0.1.7.tar.gz 23.0 kB Without provenance Details for vigilon-0.1.7.tar.gz

Built distribution (wheel)

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

Total release size: 40.1 kB

Release files / vigilon-0.1.7.tar.gz

Download URL vigilon-0.1.7.tar.gz
Size 23.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d88edbcc15219f9ee85caf1725056f4d66956a7f4100c376bcd49f4041e09757
BLAKE2b-256 checksum
How to use checksums
ad880f6463233cf2898579dd23cab53533d5274e21f7cb23a107cb446d38fa2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / vigilon-0.1.7-py3-none-any.whl

Download URL vigilon-0.1.7-py3-none-any.whl
Size 17.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b0fae54f5b738d2f784abf592cf1639eed9c87158a44c7f064eedaf4367aa6b
BLAKE2b-256 checksum
How to use checksums
a781d401ee875d9adfe71187b0d4cab2fdf99a3ef32a29d7b167916c80ccdc95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for vigilon 0.1.7

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.

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files No provenance

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