docker / buildx

Docker CLI plugin for extended build capabilities with BuildKit
Apache License 2.0
3.33k stars 448 forks source link

metrics for bake command #2519

Open crazy-max opened 3 weeks ago

crazy-max commented 3 weeks ago

Since Buildx v0.13.0 we support exporting OpenTelemetry metrics for the build command. We currently track: https://github.com/docker/buildx/blob/3b25e3fa5c0aaad475a7516cfe852262db26b068/util/progress/metricwriter.go#L29-L34

We should do the same for bake with slight changes/enhancements. For example we should track the underlying attributes within the loaded bake definition for built targets and one thing that would be interesting to set along the attributes is what kind of files are being consumed (hcl, compose, json) when merging the definition. This would help understand user's workflow.

crazy-max commented 2 weeks ago

@jsternberg Started something to implement metrics for bake based on your work for build command: https://github.com/docker/buildx/compare/master...crazy-max:buildx:bake-metrics

Current attributes need more work I think. We need to set the context and dockerfile path for each target. Would need to have the bake definitions and targets loaded first though. Also wonder if we need a metric for each target?

jsternberg commented 1 week ago

I think we might want to identify what things we want to measure from bake similar to what we did for build. We presently measure the following metrics:

For bake, do we want to measure these same attributes? Do we want to measure these attributes per target in the bake execution? I think it might be too complicated to measure these particular metrics in a per-target way because the underlying implementation executes all of them at the same time and I don't think these metrics would be very accurate or the most useful.

For build, we include a build options hash to try and get a way to correlate the same invocations with each other. This happens to include the context and dockerfile for build. For bake, I'd argue that we want to use different attributes for that. Maybe just the targets and the name of the bakefile definition?