Configuration

Configuration

Configure the client with constructor arguments, environment variables, or both. Explicit arguments win over environment variables, which win over the built-in defaults.

Constructor options

All constructor parameters mirror the environment variables below, plus a set of advanced delivery and privacy options. The same arguments are accepted by rollout.init(...).

config.py
client = Rollout(    api_key="...",    agent_name="support_agent",    environment="production",    sample_rate=0.5,              # keep 50% of traces    sync_mode=True,               # send immediately (tests/debugging only)    debug=True,                   # verbose logging    disabled=False,    before_send=lambda e: e,      # mutate or drop events before enqueue    capture_stream_chunks=False,  # persist every token (off by default))

Identity & routing

These describe where events go and how runs are labeled. Each has a matching environment variable (see below).

OptionTypeDefaultDescription
api_keystr | NoneWorkspace API key.
base_urlstrhosted endpointOverride the ingest endpoint.
environmentstr | NoneNoneDeployment environment, e.g. production.
releasestr | NoneNoneApp version or git SHA.
service_namestr | NoneNoneService identifier.
agent_namestr | NoneNoneDefault agent name for traces.
agent_idstr | NoneNoneAgent ID.
agent_versionstr | NoneNoneAgent version.
deploymentstr | NoneNoneDeployment slot or region.

Delivery & behavior

These control batching, sampling, privacy, and streaming. They are constructor-only — there are no environment variables for the queue and batch tuning options.

OptionTypeDefaultDescription
sample_ratefloat1.0Fraction of traces to keep (0.0–1.0).
sync_modeboolFalseSend events inline in the calling thread (tests only).
debugboolFalseVerbose logging.
disabledboolFalseTurn the SDK into a no-op.
before_sendcallable | NoneNoneMutate an event, or return None to drop it.
scrubbercallable | NoneNoneRedact or strip fields on every event.
send_default_piiboolFalseWhether to send default PII. Never required.
capture_stream_chunksboolFalsePersist every streamed token.
stream_preview_charsint4096Size of the rolling stream preview.
auto_instrumenttuple[str, ...]()Provider names to instrument automatically.
max_queue_eventsint1000Max events buffered in memory.
max_queue_bytesint4 MBMax bytes buffered in memory.
max_batch_eventsint100Max events per outgoing batch.
max_batch_bytesint512 KBMax bytes per outgoing batch.
flush_intervalfloat2.0Seconds between automatic flushes.
shutdown_timeoutfloat5.0Seconds to wait for the queue to drain on shutdown.

Note

before_send and scrubber are covered in detail on Privacy & redaction.

Environment variables

Set these instead of passing arguments — handy for keeping configuration out of code and switching behavior per deployment.

VariableDescription
ROLLOUT_API_KEYAPI key.
ROLLOUT_BASE_URLOverride ingest endpoint.
ROLLOUT_ENVIRONMENTDeployment environment, e.g. production.
ROLLOUT_RELEASEApp version or git SHA.
ROLLOUT_SERVICE_NAMEService identifier.
ROLLOUT_AGENT_NAMEAgent name.
ROLLOUT_AGENT_IDAgent ID.
ROLLOUT_AGENT_VERSIONAgent version.
ROLLOUT_DEPLOYMENTDeployment slot or region.
ROLLOUT_SAMPLE_RATETrace sample rate (0.0–1.0).
ROLLOUT_DEBUGEnable verbose logging (true/false).
ROLLOUT_DISABLEDDisable the SDK entirely (true/false).

Tip

Boolean variables accept 1/true/yes/on and 0/false/no/off (case-insensitive). Empty string values are treated as unset.

Sampling

sample_rate keeps a fraction of traces. Sampling is decided per trace: once a trace is sampled in, all of its spans and events are kept, so you never get partially-sampled traces. A rate of 1.0 (the default) keeps everything; 0.0 keeps nothing.

Disabling the SDK

Set disabled=True or ROLLOUT_DISABLED=trueto turn the SDK into a no-op without changing application code — useful for tests, CI, local scripts, and as an emergency kill-switch. Traces, spans, and decorators still run your code; they just don't emit events.