Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sidmanale643/northstar/llms.txt
Use this file to discover all available pages before exploring further.
northstar.init() bootstraps the NorthStar SDK and starts the background flush worker that batches telemetry records and ships them to the ingest endpoint. It should be called once, early in your application startup — before any calls to trace(), observe(), span(), or the logging helpers. All parameters are keyword-only. Credentials can be supplied directly or resolved automatically from environment variables.
Function signature
Parameters
Your NorthStar API key (begins with
ns_). Falls back to the NORTHSTAR_API_KEY environment variable when not provided. Required for data to be sent; without it the SDK runs in no-op mode.Your Supabase project reference (e.g.
abcdefghijklmnop). Used to derive the ingest URL as https://{project_id}.supabase.co/functions/v1/ingest-traces. Falls back to NORTHSTAR_PROJECT_ID. Either project_id or a custom endpoint must be present for ingestion to be active.Override the ingest URL entirely. Useful for self-hosted deployments. Falls back to
NORTHSTAR_ENDPOINT. Takes precedence over the URL derived from project_id.A human-readable project name (e.g.
"Support Agent"). Stored in every run’s metadata and visible in the dashboard. Falls back to NORTHSTAR_PROJECT.Deployment environment label (e.g.
"production", "staging", "dev"). Stored in every run’s metadata. Falls back to NORTHSTAR_ENVIRONMENT.Master on/off switch. When
False, all SDK calls become no-ops — no network requests, no background threads. Defaults to True (or the value of NORTHSTAR_ENABLED, which accepts 1/true/yes/on and 0/false/no/off).Print internal SDK warnings to
stderr (prefixed with [NorthStar]). Useful when diagnosing dropped records or flush failures. Defaults to False (or NORTHSTAR_DEBUG).Whether to capture function arguments and user inputs as trace events globally. Can be overridden per-trace with
@northstar.trace(capture_input=False).Whether to capture return values and final responses as trace events globally. Can be overridden per-trace with
@northstar.trace(capture_output=False).Additional key names whose values should be replaced with
"[REDACTED]" before any data is enqueued. The SDK always redacts api_key, authorization, cookie, password, secret, and token by default; keys passed here are merged with that built-in set. Matching is case-insensitive and recursive (works inside nested dicts, lists, Pydantic models, and dataclasses).Number of queued records that triggers an early flush without waiting for
flush_interval. Must be greater than zero; raises ValueError otherwise.Seconds between scheduled background flushes. The background worker wakes every
flush_interval seconds to send whatever is queued. Must be greater than zero; raises ValueError otherwise.Maximum total number of pending records (sessions + runs + spans + events) held in memory. Records are silently dropped when the queue is full (a warning is printed if
debug=True). Must be greater than zero; raises ValueError otherwise.Environment variable reference
| Parameter | Environment variable | Default |
|---|---|---|
api_key | NORTHSTAR_API_KEY | none |
project_id | NORTHSTAR_PROJECT_ID | none |
endpoint | NORTHSTAR_ENDPOINT | derived from project_id |
project | NORTHSTAR_PROJECT | none |
environment | NORTHSTAR_ENVIRONMENT | none |
enabled | NORTHSTAR_ENABLED | true |
debug | NORTHSTAR_DEBUG | false |
Basic usage
Advanced configuration
init_logger() alias
northstar.init_logger() is a convenience alias for init(). It accepts the same parameters with one small difference: api_key and project are required keyword arguments (not optional). Use it as a drop-in replacement if you prefer the name.
Re-initialization
Callinginit() a second time is safe. The SDK shuts down the previous state — flushing any pending records and closing the background worker — then starts fresh with the new configuration. All traces created after the second init() call share a new session.
Traces that are already in flight when
init() is called finish on their
original state object and are flushed as part of the shutdown sequence, so no
data is lost mid-trace.No-op mode
Whenenabled=False, or when neither api_key nor project_id/endpoint is available, the SDK enters no-op mode. Every API call succeeds silently — decorators execute the wrapped function normally, context managers yield a stub handle, and flush() returns True immediately. This lets you import and call NorthStar unconditionally without affecting test environments.