Skip to main content

nolax-sdk (Python)

Python SDK for Nolax, API observability for your applications. It installs as middleware in Flask, Django or FastAPI, captures request metadata (method, route, status, latency, size) and sends it to Nolax in batches from a background thread, without slowing your application.

  • Python 3.8 or newer, no runtime dependencies.
  • Flask 2.0+, Django 4.2+, FastAPI/Starlette 0.95+ (install whichever you use; none is required).

Installation

pip install nolax-sdk

Quick start

Flask

from flask import Flask
from nolax import NolaxFlask

app = Flask(__name__)
NolaxFlask(api_key="nlx_proj_xxx", environment="production").init_app(app)

FastAPI

from fastapi import FastAPI
from nolax import NolaxFastAPI

app = FastAPI()
app.add_middleware(NolaxFastAPI, api_key="nlx_proj_xxx", environment="production")

Django

# settings.py
MIDDLEWARE = [
    # ...
    "nolax.middleware.NolaxDjango",
]
NOLAX_API_KEY = "nlx_proj_xxx"
NOLAX_ENVIRONMENT = "production"

Every other option is a setting named NOLAX_<OPTION>, for example NOLAX_BATCH_SIZE or NOLAX_IP_HEADER.

Options

Option names match case-insensitively and ignore underscores, so flush_interval_ms, flushIntervalMs and FlushIntervalMs are the same option.

Option Default Description
api_key required Your Nolax project API key
environment required development, staging or production (case-insensitive). Any other value logs one error and disables the SDK
endpoint https://server.nolax.net/ingest Override for staging and load tests
batch_size 100 Events that trigger a flush
flush_interval_ms 2000 Milliseconds between timer-based flushes. The old flush_interval (seconds) still works and is deprecated
max_queue_size 10000 Events held in memory; the oldest are dropped first
max_in_flight 4 Batches that may wait for the sender thread. Python sends one batch at a time from one thread over one persistent connection
release none Release identifier, sent once per batch (max 64 characters)
service none Service name, sent once per batch (max 64 characters)
consumer none callable(request) -> str returning a consumer id (max 64 characters). Receives the Flask or Django request, or the ASGI scope
capture_ip True When False, the client IP is never sent
capture_user_agent True When False, the User-Agent is never sent
ip_header none Header holding the client IP behind a proxy, for example x-forwarded-for (first entry) or cf-connecting-ip. Used only when set
ignore_paths none Strings or compiled patterns; matching requests are never recorded, for example "/health"
ignore_methods none Methods that are never recorded, for example ["OPTIONS"]
before_send none callable(event) -> event or None. Modify an event, or return None to drop it. Must be synchronous. If it raises, the event is dropped
dry_run False Print each batch that would be sent (API key masked as nlx_proj_****) and send nothing. NOLAX_DRY_RUN=1 does the same
debug False Verbose logging through the nolax logger. Never prints the API key
on_error none callable(exception) invoked when a batch is dropped

Behaviour worth knowing

  • payloadSize is the response Content-Length header, or 0 when it is absent (for example streamed responses). The SDK never reads a response body, so streaming responses are not consumed.
  • If your view raises, the event is recorded with status 500 and the exception class name (never the message). The exception is re-raised unchanged.
  • On a rejected API key or a reached plan limit the SDK pauses sending for 60 seconds, doubling up to 15 minutes, and discards events meanwhile.
  • The server can adjust batch size, flush interval and backoff through response hints, within fixed bounds.
  • The flush timer and sender thread start on first use and start again in each forked worker, so gunicorn and uWSGI with preloaded apps work.
  • On interpreter exit the SDK flushes with a 2 second limit and then stops waiting. It installs no signal handlers. Call flush() yourself if your process exits another way:
nolax = NolaxFlask(api_key="nlx_proj_xxx", environment="production")
nolax.flush(2.0)

Development

pip install -e ".[dev]"
pytest

Ingest contract

Version 1.1 (additive over 1.0). Older servers keep working.

Metadata

Release files for nolax-sdk 1.1.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 nolax-sdk 1.1.0
File Size Uploaded Provenance Actions
nolax_sdk-1.1.0.tar.gz 34.0 kB Without provenance Details for nolax_sdk-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nolax-sdk 1.1.0
File Interpreter ABI Platform Actions
nolax_sdk-1.1.0-py3-none-any.whl Python 3 none any Details for nolax_sdk-1.1.0-py3-none-any.whl

Total release size: 55.8 kB

Release files / nolax_sdk-1.1.0.tar.gz

Download URL nolax_sdk-1.1.0.tar.gz
Size 34.0 kB
Tags Source
SHA-256 checksum
How to use checksums
aad8b68e5e86b3bc6b53e04ed81f2c033e521395a6b363da6184bcd2063c4e06
BLAKE2b-256 checksum
How to use checksums
5bf9efbd761fa5b8242d9dd1c358e396d4c261790ccdb71c81b3b31c0bcfcdc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / nolax_sdk-1.1.0-py3-none-any.whl

Download URL nolax_sdk-1.1.0-py3-none-any.whl
Size 21.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c75105ee7875f90ee76b66e526154d07d9ffb352ead3977d8befc10134912f6a
BLAKE2b-256 checksum
How to use checksums
3a83af9f2505ba75c79d1982ff4b6ef6e8a1c625609d95bb55dac11363eb253b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for nolax-sdk 1.1.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