Environment variables
Several init() arguments can be supplied via environment variables instead. An explicit argument to
init() always takes precedence over the corresponding variable.
| Variable | Equivalent init() argument |
|---|---|
METRANA_API_KEY |
api_key |
METRANA_ORCHESTRATION_ID |
orchestration_id |
METRANA_INGESTION_URL |
ingestion_url |
METRANA_ARTIFACT_API_URL |
artifact_api_url |
METRANA_QUERY_API_URL |
query_api_url |
METRANA_BACKPRESSURE_STRATEGY |
backpressure_strategy |
METRANA_DELIVERY_POLICY |
delivery_policy |
METRANA_RENDERING_ERROR_STRATEGY |
rendering_error_strategy |
METRANA_RESUME_STRATEGY |
resume_strategy |
METRANA_INIT_MODE |
init_mode |
METRANA_DISK_SPOOL_DIR |
disk — the base directory of the default spool (~/.metrana/spools; the spool lives under <base>/<hostname>); an explicit disk= argument ignores it |
METRANA_LOG_LEVEL |
log_level |
METRANA_EVENT_QUEUE_MAX_SIZE |
queue_capacity |
METRANA_SKIP_DRAIN_RENDER_ON_CLOSE |
skip_drain_render_on_close |
METRANA_RENDERING_CLOSE_TIMEOUT |
rendering_close_timeout |
Environment-only variables
Section titled “Environment-only variables”These have no init() equivalent — they can only be set in the environment.
| Variable | Default | Meaning |
|---|---|---|
METRANA_RENDER_ERROR_QUEUE_MAX_SIZE |
1000 |
Maximum number of buffered rendering errors. Set to 0 for unbounded. |
NO_COLOR |
(unset) | If set to anything, SDK warnings are written without ANSI color codes. Follows the NO_COLOR convention. Color is only used for a TTY regardless. |
METRANA_API_KEYis the most common one — set it in your environment so you never hard-code a key:It’s also the fallback used byTerminal window export METRANA_API_KEY="your-api-key"replay_spool.METRANA_INGESTION_URL,METRANA_ARTIFACT_API_URLandMETRANA_QUERY_API_URLpoint the SDK at a self-hosted or staging deployment without touching your code — see Service endpoints.METRANA_INGESTION_URLis also the fallback used byreplay_spooland themetrana migrateCLI (--ingestion-url):Terminal window export METRANA_INGESTION_URL="https://ingestion.staging.example.com"METRANA_ORCHESTRATION_IDis auto-populated by the SDK after resolution, so forked/spawned children inherit the same run. See Distributed logging.- Framework job ids (
TORCHELASTIC_RUN_ID,SLURM_JOB_ID,RAY_JOB_ID) are read automatically to resolve the orchestration id whenMETRANA_ORCHESTRATION_IDis unset — you don’t set these yourself.