@@ -25,6 +25,10 @@ import (
2525 "github.com/moby/buildkit/exporter/containerimage/exptypes"
2626 "github.com/moby/buildkit/session/secrets/secretsprovider"
2727 "github.com/pkg/errors"
28+ "go.opentelemetry.io/otel/attribute"
29+ "go.opentelemetry.io/otel/trace"
30+ "golang.org/x/sync/errgroup"
31+
2832 "github.com/superfly/flyctl/helpers"
2933 "github.com/superfly/flyctl/internal/buildinfo"
3034 "github.com/superfly/flyctl/internal/cmdfmt"
@@ -34,9 +38,6 @@ import (
3438 "github.com/superfly/flyctl/internal/tracing"
3539 "github.com/superfly/flyctl/iostreams"
3640 "github.com/superfly/flyctl/terminal"
37- "go.opentelemetry.io/otel/attribute"
38- "go.opentelemetry.io/otel/trace"
39- "golang.org/x/sync/errgroup"
4041)
4142
4243type dockerfileBuilder struct {}
@@ -270,10 +271,12 @@ func (*dockerfileBuilder) Run(ctx context.Context, dockerFactory *dockerClientFa
270271 build .BuildFinish ()
271272 cmdfmt .PrintDone (streams .ErrOut , "Building image done" )
272273
274+ builderType , builderRegion := getBuilderInfo (ctx , dockerFactory )
275+
273276 if opts .Publish {
274277 build .PushStart ()
275278 tb := render .NewTextBlock (ctx , "Pushing image to fly" )
276- if err := pushToFly (ctx , docker , streams , opts .Tag ); err != nil {
279+ if err := pushToFly (ctx , docker , streams , opts .Tag , builderType , builderRegion ); err != nil {
277280 build .PushFinish ()
278281 return nil , "" , err
279282 }
@@ -521,7 +524,7 @@ func runBuildKitBuild(ctx context.Context, docker *dockerclient.Client, opts Ima
521524 return res .ExporterResponse [exptypes .ExporterImageDigestKey ], nil
522525}
523526
524- func pushToFly (ctx context.Context , docker * dockerclient.Client , streams * iostreams.IOStreams , tag string ) (err error ) {
527+ func pushToFly (ctx context.Context , docker * dockerclient.Client , streams * iostreams.IOStreams , tag string , builderType string , builderRegion string ) (err error ) {
525528 ctx , span := tracing .GetTracer ().Start (ctx , "push_image_to_registry" , trace .WithAttributes (attribute .String ("tag" , tag )))
526529 defer span .End ()
527530
@@ -531,6 +534,12 @@ func pushToFly(ctx context.Context, docker *dockerclient.Client, streams *iostre
531534 }
532535 }()
533536
537+ // Add builder type and region to span attributes
538+ span .SetAttributes (
539+ attribute .String ("builder.type" , builderType ),
540+ attribute .String ("builder.region" , builderRegion ),
541+ )
542+
534543 metrics .Started (ctx , "image_push" )
535544 sendImgPushMetrics := metrics .StartTiming (ctx , "image_push/duration" )
536545
@@ -543,6 +552,9 @@ func pushToFly(ctx context.Context, docker *dockerclient.Client, streams *iostre
543552 return errors .Wrap (err , "error pushing image to registry" )
544553 }
545554 defer pushResp .Close () // skipcq: GO-S2307
555+
556+ // Send enhanced metrics with builder type and region
557+ SendEnhancedImagePushMetrics (ctx , builderType , builderRegion )
546558 sendImgPushMetrics ()
547559
548560 err = jsonmessage .DisplayJSONMessagesStream (pushResp , streams .ErrOut , streams .StderrFd (), streams .IsStderrTTY (), nil )
@@ -559,3 +571,12 @@ func pushToFly(ctx context.Context, docker *dockerclient.Client, streams *iostre
559571
560572 return nil
561573}
574+
575+ // SendEnhancedImagePushMetrics sends enhanced metrics for image push operations
576+ // with builder type and region information
577+ func SendEnhancedImagePushMetrics (ctx context.Context , builderType , builderRegion string ) {
578+ metrics .Send (ctx , "image_push/enhanced" , map [string ]interface {}{
579+ "builder_type" : builderType ,
580+ "builder_region" : builderRegion ,
581+ })
582+ }
0 commit comments