mirai provides comprehensive OpenTelemetry (otel) tracing support for observing asynchronous operations and distributed computation.
When the otel and otelsdk packages are
installed and tracing is enabled, mirai automatically creates spans to
track the lifecycle of daemon management, async operations, and task
execution.
This enables detailed monitoring of:
Tracing is automatically enabled when:
otel and otelsdk packages are
installed and availableNo additional configuration is required - mirai will automatically detect the presence of OpenTelemetry and begin creating spans.
mirai creates several types of spans to represent different operations:
mirai::daemons - Root span for daemon
management
internal
url, n
(number of daemons), dispatcher (true/false),
compute_profile
daemons() is
called, ended when daemons are resetmirai::daemon - Individual daemon
process span
internal
mirai::mirai_map - Parallel map
operation span
internal
mirai::mirai - Client-side async task
span
client
mirai.id (unique task
identifier)mirai() is
called, ended as soon as it returnsmirai::daemon->eval - Server-side
task evaluation span
server
The spans form a distributed structure that traces the complete lifecycle of async operations:
mirai::daemons (compute profile - top level)
mirai::daemon (daemon process 1 - top level)
mirai::daemon (daemon process 2 - top level)
mirai::daemon (daemon process N - top level)
mirai::mirai_map (top level)
├── mirai::mirai (task 1) ──link→ mirai::daemons
├── mirai::mirai (task 2) ──link→ mirai::daemons
└── mirai::mirai (task N) ──link→ mirai::daemons
└── mirai::daemon->eval ──link→ mirai::daemon
mirai::mirai (top level) ──link→ mirai::daemons
└── mirai::daemon->eval ──link→ mirai::daemon
Context Propagation: The context is automatically
packaged with each mirai() call and extracted on the daemon
side, enabling proper parent-child relationships across process
boundaries.
Span Links: Tasks are linked to their compute
profile’s mirai::daemons span on the client side, and to
each mirai::daemon span on the server side, showing exactly
where each evaluation happened.
mirai::daemon->eval spans automatically track the
success or failure of operations:
Status Values:
'ok' or 'unset' - Operation completed
successfully'error', with description 'miraiError' -
Operation failed with an error'error', with description 'miraiInterrupt'
- Operation was interruptedThe OpenTelemetry spans provide rich observability into mirai operations:
Performance Monitoring:
Error Analysis:
Distributed Tracing:
mirai’s OpenTelemetry implementation works seamlessly with any OpenTelemetry-compatible observability platform, including:
The tracer name used by mirai is "org.r-lib.mirai",
making it easy to filter and identify mirai-related traces in your
observability platform.