metrics for bake command
crazy-max opened this issue · 5 comments
Since Buildx v0.13.0 we support exporting OpenTelemetry metrics for the build
command. We currently track:
buildx/util/progress/metricwriter.go
Lines 29 to 34 in 3b25e3f
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.
@jsternberg Started something to implement metrics for bake based on your work for build command: 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?
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:
- local source transfer
- image source transfer
- execution time
- export time
- idle time
- which lints were recorded
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?
I have an implementation here that should close this issue: #2610
It reports the same metrics as the build command and uses a different method of computing the build identifier. I don't attempt to differentiate between different builds within the bake command since bake runs them all at the same time and in parallel if possible, so I think differentiating which action applies to which target would be too difficult. This should still give us a bunch of information about how bake is used and we can expand it to also include the number of targets or number of files that were used if we want to.
Implementation is in #2610 as noted above. Follow-on required for integration tests, let's keep this issue open until the tests are added.