action, test and test_attempt spans require Aspect CLI v2026.46.21 or later. spawn spans, the build, phase, task and spawn duration metrics, and the --telemetry:build-events and --telemetry:execution-log flags require v2026.47.2 or later.
Send to a collector
Set the standard OpenTelemetry environment variables:
In CI, set them from a secret. The
Telemetry feature registers an exporter from the endpoint variables; set discover_endpoints = False to stop it. The headers, timeout and resource attributes still apply to every OTLP exporter, including those registered in config.axl.
Everything exported carries the resource attributes service.name=aspect-cli and service.version.
Honeycomb
https://api.eu1.honeycomb.io:443 for an EU team. Traces land in the aspect-cli dataset and metrics in the one x-honeycomb-dataset names.
Datadog
Enable the OTLP receiver on the Datadog Agent running on the CI machine:datadog.yaml
Configure exporters in config.axl
For more than one collector, a signal routed to its own collector, extra resource attributes, or credentials read at run time, register exporters in.aspect/config.axl:
.aspect/config.axl
ctx.telemetry.exporters.add takes:
A feature’s implementation can call the same function through its
FeatureContext, for example to register an exporter only on one CI host.
For a single invocation, pass the endpoint as a flag. It repeats, and each one uses gRPC with every signal:
What is exported
One trace per invocation:events comes from the build event stream and spawns from the execution log; Choose what each build exports sets when each is on.
action, test and test_attempt take their start and end times from Bazel. A cached test did no work in this build, so its test_attempt and test are zero-length spans at the moment the build reported the result, with cached set. A test with only some attempts cached spans the attempts that ran. Match a test_attempt to its test by label.
Bazel reports only failed actions to the CLI. To get an action span for every action, add --build_event_publish_all_actions to your .bazelrc. On a large build that is a lot of spans.
startup_ms on root is the time from the CLI starting until the task begins, not counting the launcher. The startup.<step> spans, together with eval, execute.configs and execute.features, show where that time went.
A spawn span starts and ends when Bazel says the spawn did, so a cache hit spans its lookup and download. It carries:
Span events on
build_tool record each target’s result (target_completed), the parsed command line (options_parsed) and every external download (fetch). Logs are the CLI’s own log lines, not Bazel’s output.
Choose what each build exports
A Bazel build feeds telemetry from two streams. A flag on theTelemetry feature sets when each one does, for its spans and metrics together:
always on the execution log costs Bazel the I/O of writing it. Either stream needs an OTLP exporter that takes traces or metrics; without one, always turns nothing on. For the metrics without the spans, register the exporter with signals = ["metrics"].
Set either for every invocation in config.axl. A flag left at auto keeps that setting:
.aspect/config.axl
Metrics
None carries a target label, so the number of series stays bounded however large the repository. Metrics use delta temporality and are exported every 30 seconds and when the CLI exits. Set
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE or OTEL_METRIC_EXPORT_INTERVAL to change either.
Debug locally
ASPECT_DEBUG=1 prints the CLI’s log lines and trace events to stderr, including the exporters it registered:
format is compact or jsonl:
.aspect/config.axl
ASPECT_TELEMETRY_SHUTDOWN_TIMEOUT_MS to change that.
Spans wait in a queue of 8192 to be exported, 2048 at a time. A span that ends while the queue is full is dropped, and the CLI prints how many it dropped, and how many failed to export, as it exits. When an export fails, the CLI also prints the first export error for spans, metrics and logs, for example a gRPC Unauthenticated from the collector. Set OTEL_BSP_MAX_QUEUE_SIZE and OTEL_BSP_MAX_EXPORT_BATCH_SIZE to change the queue and batch sizes.
