An OpenTelemetry Collector custom receiver designed to receive Bazel Build Event Protocol (BEP) streams via the BES gRPC API and converts them into the OpenTelemetry trace model. Bazel builds become trace flamegraphs in Datadog, Tempo, Jaeger, or any OTLP backend.
# Install the OpenTelemetry Collector Builder (OCB)
go install go.opentelemetry.io/collector/cmd/builder@v0.146.1
# Build the collector binary
make ocb./build/otelcol-bazel --config collector-config.yamlbazel build //... \
--bes_backend=grpc://localhost:8082 \
--build_event_publish_all_actionsThe
--build_event_publish_all_actionsflag is required -- without it, only failed actions emit events.
Each Bazel invocation produces one trace:
bazel.build (root span, traceID derived from invocation UUID)
├── bazel.target (//pkg:lib)
│ ├── bazel.action (Javac)
│ └── bazel.action (Turbine)
├── bazel.target (//pkg:test)
│ ├── bazel.test (shard=0, run=1, attempt=1)
│ └── bazel.test (shard=1, run=1, attempt=1)
└── bazel.metrics (wall_time, cpu_time, actions_executed)
The receiver is configured under receivers.bes in the collector YAML. It embeds the standard configgrpc.ServerConfig (endpoint, TLS, keepalive) plus BES-specific tuning parameters (invocation_timeout, reaper_interval). See collector-config.yaml for a working example and config.go for the full schema.
make test # Run tests (with race detector, no cache)
make lint # Run golangci-lint
make vet # Run go vet
make build # Verify compilation
make ci # Run the full CI chain: vet → lint → test → build
make test-bench # Run benchmarks
make fuzz # Run fuzz testsOptional: install the prek git hooks to lint staged Go packages on commit and the full module on push (CI remains the source of truth):
make pre-commit-install # cargo binstall prek + wire up commit & push hooks
make pre-commit # fast: lint changed packages
make pre-push # slow: lint the whole root module- Architecture -- system overview, internal components, and span hierarchy
- Sequence diagrams -- BEP stream processing flow
- Attributes -- span attributes and PII controls
- Filtering -- per-target detail levels to control trace verbosity
See LICENSE.