mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 10:03:42 +08:00 
			
		
		
		
	metrics: send metrics to the otel collector endpoint when active
Introduce a meter provider to the buildx cli that will send metrics to the otel-collector included in docker desktop if enabled. This will send usage metrics to the desktop application but also send metrics to a user-provided otlp receiver endpoint through the standard environment variables. This introduces a single metric which is the cli count for build and bake along with the command name and a few additional attributes. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
		@@ -19,6 +19,7 @@ import (
 | 
			
		||||
	"github.com/docker/buildx/util/confutil"
 | 
			
		||||
	"github.com/docker/buildx/util/desktop"
 | 
			
		||||
	"github.com/docker/buildx/util/dockerutil"
 | 
			
		||||
	"github.com/docker/buildx/util/metrics"
 | 
			
		||||
	"github.com/docker/buildx/util/progress"
 | 
			
		||||
	"github.com/docker/buildx/util/tracing"
 | 
			
		||||
	"github.com/docker/cli/cli/command"
 | 
			
		||||
@@ -45,6 +46,14 @@ type bakeOptions struct {
 | 
			
		||||
func runBake(dockerCli command.Cli, targets []string, in bakeOptions, cFlags commonFlags) (err error) {
 | 
			
		||||
	ctx := appcontext.Context()
 | 
			
		||||
 | 
			
		||||
	mp, report, err := metrics.MeterProvider(dockerCli)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	defer report()
 | 
			
		||||
 | 
			
		||||
	recordVersionInfo(mp, "bake")
 | 
			
		||||
 | 
			
		||||
	ctx, end, err := tracing.TraceCurrentCommand(ctx, "bake")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user