Repository navigation
solver/llbsolver: emit native build-completion metrics - #6736
Merged
Merged
Conversation
asbarron
marked this pull request as ready for review
May 3, 2026 21:04
asbarron
force-pushed
the
asbarron/buildkit-build-metrics
branch
from
May 5, 2026 19:10
06abd34 to
c2a5c1d
Compare
jsternberg
requested changes
May 20, 2026
jsternberg
left a comment
Collaborator
There was a problem hiding this comment.
A few suggested changes but I like the direction this is going.
asbarron
force-pushed
the
asbarron/buildkit-build-metrics
branch
from
May 23, 2026 00:53
c2a5c1d to
2784489
Compare
Contributor
Author
|
Addressing @jsternberg's review feedback:
|
asbarron
force-pushed
the
asbarron/buildkit-build-metrics
branch
from
May 23, 2026 01:04
2784489 to
1e3882e
Compare
jsternberg
approved these changes
May 27, 2026
Collaborator
|
Please rebase and resolve the conflicts and then this should be good to go. |
Threads the existing OTEL MeterProvider through llbsolver.Opt and emits three build-event instruments from the recordBuildHistory finalizer: - buildkit.builds (counter; labels: status, error_code) - buildkit.builds.steps (counter; labels: kind) - buildkit.build.duration (Base2 exponential histogram; labels: status) The duration histogram uses an exponential aggregation, rendered as a Prometheus native histogram by the existing exporter, to avoid the "tens of millions of series" cardinality blow-up reported in moby#5777. MeterProvider is passed explicitly through the constructor — buildkit policy (per the moby#4957 review) prohibits relying on the OTel global provider in library packages. error_code uses gRPC codes.Code.String() for a bounded set; rec.Error.Message is intentionally never used as a label. The frontend label is intentionally omitted — client.Build clears req.Frontend on the wire, so the field is empty for every caller that goes through the gateway-client API (buildctl, buildx). The metric is forward-compatible with a future buildkit change that populates rec.Frontend on that path. A follow-up PR will add observable gauges for worker count and cache state, plus an operator guide at docs/metrics.md. Refs moby#1544; addresses discussion moby#5777. Signed-off-by: Ava Barron <abarron@coreweave.com>
Signed-off-by: Ava Barron <abarron@coreweave.com>
asbarron
force-pushed
the
asbarron/buildkit-build-metrics
branch
from
May 28, 2026 16:59
1e3882e to
d89811c
Compare
tonistiigi
approved these changes
Jun 3, 2026
chagui
added a commit
to chagui/buildkit
that referenced
this pull request
Jul 22, 2026
Adds buildkit.active_solves, an asynchronous observable gauge reporting the count of currently in-flight non-internal Solve RPCs. The metric is intended as a live, per-pod autoscaling signal: every existing buildkit metric either lags long solves (RPC counters fire only at completion, including the buildkit.builds counter introduced in moby#6736) or sits at a fixed pool size (goroutine, thread, runc worker counts). The gauge is backed by an atomic.Int64 on buildMetrics, incremented at Solver.Solve entry and decremented via defer. Internal sub-solves (gateway frontends invoking the solver recursively) are excluded to avoid double-counting work that nests under a parent RPC. The instrument is registered against the MeterProvider plumbed through llbsolver.Opt by moby#6736; the OTel global provider is intentionally not used, per buildkit library-package policy. Stacks on moby#6736. Signed-off-by: Guilhem Charles <guilhem.charles@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Threads the existing OTEL MeterProvider through
llbsolver.Optand emits three build-event instruments from the recordBuildHistory finalizer:The duration histogram uses an exponential aggregation, rendered as a Prometheus native histogram by the existing exporter, to avoid the "tens of millions of series" cardinality blow-up reported by #5777.
MeterProvideris passed explicitly through the constructor; buildkit policy (from the #4957 review) prohibits relying on the OTel global provider in library packages.error_codeuses gRPCcodes.Code.String()for a bounded set; rec.Error.Message is intentionally never used as a label.The frontend label is intentionally omitted because
client.Buildclearsreq.Frontendon the wire, so the field is empty for every caller that goes through the gateway-client API (buildctl, buildx). The metric is forward-compatible with a future buildkit change that populatesrec.Frontendon that path.A follow-up PR will add observable gauges for worker count and cache state, and an operator guide at docs/metrics.md.
Refs #1544; addresses discussion #5777.