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; andNo additional action is required - mirai will automatically detect the presence of OpenTelemetry and begin tracing.
mirai creates several types of spans to represent different operations.
daemons set / daemons reset
Root span for a compute profile, created when daemons are set, and when they are reset. The span name includes the URL for easy identification.
internalserver.address (e.g. ‘127.0.0.1’ or ‘hostname’)server.port (where applicable)network.transport (e.g. ‘tcp’ or ‘ipc’)mirai.dispatcher (true/false)mirai.compute (profile name)daemon connect / daemon disconnect
Daemon process span, created when a daemon connects, and when it disconnects. The span name includes the URL for easy identification.
internalserver.address (e.g. ‘127.0.0.1’ or ‘hostname’)server.port (where applicable)network.transport (e.g. ‘tcp’ or ‘ipc’)mirai_map
Parallel map operation span. Encompasses the entire map operation across multiple mirai tasks.
internalmirai
Client-side async task span.
Created when mirai() is called and ends as soon as it returns.
clientmirai.id (unique task identifier)daemon eval
Server-side task evaluation span. Tracks for the duration of actual mirai evaluation on the daemon.
serverThe spans form a distributed structure that traces the complete lifecycle of async operations:
daemons set (compute profile - top level)
daemon connect (daemon process 1 - top level)
...
daemon connect (daemon process N - top level)
mirai_map (top level) ──link→ daemons set
├── mirai (task 1) ──link→ daemons set
│ └── daemon eval ──link→ daemon connect
├── mirai (task 2) ──link→ daemons set
│ └── daemon eval ──link→ daemon connect
└── mirai (task N) ──link→ daemons set
└── daemon eval ──link→ daemon connect
mirai (top level) ──link→ daemons set
└── daemon eval ──link→ daemon connect
daemons reset ──link→ daemons set
daemon disconnect (daemon process 1) ──link→ daemon connect
...
daemon disconnect (daemon process N) ──link→ daemon connect
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 daemons set span on the client side, and to each daemon connect span on the server side, showing exactly where each evaluation happened. When daemons are reset and the respective daemons disconnect, these events are recorded in new spans which link back to the original spans.
daemon eval spans automatically track the success or failure of operations.
Status Values
'ok' or 'unset' - completed successfully'error', with description 'miraiError' - failed with an error'error', with description 'miraiInterrupt' - 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.