This page shows how to turn logging off or on, globally or at runtime, how to silence Rerun's console output, and how to tune the micro-batching of log calls.
Controlling logging globally
Rerun logging is enabled by default. The logging behavior can be overridden at runtime using the RERUN environment variable:
export RERUN=off
python my_rerun_enabled_script.py
# or
cargo run my_rerun_package
# No log messages will be transmitted.The RERUN environment variable is read once during SDK initialization. The accepted values for RERUN are 1/on/true, and 0/off/false.
Creating a default-off setup in code
The "default-on" behavior can also be changed to a "default-off" behavior:
import rerun as rr
rr.init("rerun_example_app", default_enabled=False)
Dynamically turn logging on/off
In order to dynamically turn off logging at runtime, you can swap out the active recording with a disabled recording. When you want to turn logging back on, you simply continue to use the previous recording again.
Python
The Python API uses the global recording stream by default.
To swap it out with a no-op recording call set_global_data_recording with None.
# Disabling logging
prev_rec = rr.set_global_data_recording(None)
# …
# Re-enabling logging
rr.set_global_data_recording(prev_rec)Rust
In Rust you always pass the recording explicitly, making this fully transparent.
In order to create a no-op recording call RecordingStream::disabled().
let noop_rec = RecordingStream::disabled();Silencing console output
The settings above control the data you log to Rerun.
Rerun also prints its own messages (warnings, errors, and info) to the console.
You control those with the RUST_LOG environment variable:
RUST_LOG=error python my_script.py # only show errors
RUST_LOG=off python my_script.py # show nothing
RUST_LOG=debug rerun # show a lot moreThe defaults are:
- Python SDK:
warn. - C++ SDK, and the
rerunCLI and Viewer:info. - Rust SDK: the SDK prints through the
tracingcrate, and does not set up a subscriber itself. What is printed depends on how your application sets up logging.
A Viewer started with rr.spawn() inherits the environment, including RUST_LOG, from the process that started it.
Micro batching
The Rerun SDK automatically handles micro-batching in a background thread in order to find a sweet spot between latency and throughput, reducing metadata overhead and thus improving both bandwidth and CPU usage.
The flushing is triggered by both time and space thresholds, whichever happens to trigger first.
Configuration
You can configure these thresholds using the following environment variables:
RERUN_FLUSH_TICK_SECS
Sets the duration of the periodic tick that triggers the time threshold, in seconds.
Defaults to RERUN_FLUSH_TICK_SECS=0.2 (200ms), unless the recording stream uses a networking sink, which defaults to RERUN_FLUSH_TICK_SECS=0.008 (8ms).
RERUN_FLUSH_NUM_BYTES
Sets the size limit that triggers the space threshold, in bytes.
Defaults to RERUN_FLUSH_NUM_BYTES=2097152 (2MiB).
RERUN_FLUSH_NUM_ROWS
Sets the number of rows that drives the space threshold.
Defaults to RERUN_FLUSH_NUM_ROWS=18446744073709551615 (u64::MAX).
RERUN_CHUNK_MAX_ROWS_IF_UNSORTED
Splits a chunk if it has at least this many rows and at least one of its timelines is unsorted.
Defaults to RERUN_CHUNK_MAX_ROWS_IF_UNSORTED=8192.
Or directly from code, in Python & Rust:
"""
Shows how to configure micro-batching directly from code.
For more info, check out:
<https://rerun.io/docs/log/logging-controls#micro-batching>
"""
from datetime import timedelta
import rerun as rr
# Equivalent to configuring the following environment:
# * RERUN_FLUSH_NUM_BYTES=<+inf>
# * RERUN_FLUSH_NUM_ROWS=10
# * RERUN_FLUSH_TICK_SECS=10
config = rr.ChunkBatcherConfig(
flush_num_bytes=2**63,
flush_num_rows=10,
flush_tick=timedelta(seconds=10),
)
rec = rr.RecordingStream("rerun_example_micro_batching", batcher_config=config)
rec.spawn()
# These 10 log calls are guaranteed be batched together, and end up in the
# same chunk.
for i in range(10):
rec.log("logs", rr.TextLog(f"log #{i}"))
Backpressure
The batcher limits how much data can wait in its queues. The limit is 100 MiB by default, split between the queue into the batcher and the queue out of it. When a queue is full, log calls block until the sink catches up. This happens when you log faster than the sink can write, for example over a slow network or before a gRPC connection is made. A single chunk larger than the limit is still processed.
The limit is the max_bytes_in_flight field of ChunkBatcherConfig.
It can only be changed from Rust, and only when the recording stream is created.