mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 10:03:42 +08:00 
			
		
		
		
	The meter provider initialization that was located here has now been moved to a common area in the docker cli. This upgrades our CLI version and then uses this common code instead of our own version. As a piece of additional functionality, the docker OTEL endpoint can now be overwritten with `DOCKER_CLI_OTEL_EXPORTER_OTLP_ENDPOINT` for testing. This removes the OTLP exporter from the CLI that was previously locked behind `BUILDX_EXPERIMENTAL`. I do plan for this to return, but as a proper part of the `docker/cli` implementation rather than something special with `buildx`. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
		
			
				
	
	
		
			25 lines
		
	
	
		
			680 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			680 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package metricutil
 | 
						|
 | 
						|
import (
 | 
						|
	"context"
 | 
						|
 | 
						|
	"github.com/docker/buildx/version"
 | 
						|
	"github.com/docker/cli/cli/command"
 | 
						|
	"go.opentelemetry.io/otel"
 | 
						|
	"go.opentelemetry.io/otel/metric"
 | 
						|
)
 | 
						|
 | 
						|
// Meter returns a Meter from the MetricProvider that indicates the measurement
 | 
						|
// comes from buildx with the appropriate version.
 | 
						|
func Meter(mp metric.MeterProvider) metric.Meter {
 | 
						|
	return mp.Meter(version.Package,
 | 
						|
		metric.WithInstrumentationVersion(version.Version))
 | 
						|
}
 | 
						|
 | 
						|
// Shutdown invokes Shutdown on the MeterProvider and then reports any error to the OTEL handler.
 | 
						|
func Shutdown(ctx context.Context, mp command.MeterProvider) {
 | 
						|
	if err := mp.Shutdown(ctx); err != nil {
 | 
						|
		otel.Handle(err)
 | 
						|
	}
 | 
						|
}
 |