From dade5f3d64ba8db493a35894b8c1e0a38c7cce59 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Mon, 25 Sep 2023 14:41:24 +0000 Subject: [PATCH] fix: refine create volume metrics --- pkg/blob/controllerserver.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/blob/controllerserver.go b/pkg/blob/controllerserver.go index 9163e5da6..1268ed968 100644 --- a/pkg/blob/controllerserver.go +++ b/pkg/blob/controllerserver.go @@ -316,6 +316,13 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) GetLatestAccountKey: getLatestAccountKey, } + var volumeID string + mc := metrics.NewMetricContext(blobCSIDriverName, "controller_create_volume", d.cloud.ResourceGroup, d.cloud.SubscriptionID, d.Name) + isOperationSucceeded := false + defer func() { + mc.ObserveOperationWithResult(isOperationSucceeded, VolumeID, volumeID) + }() + var accountKey string accountName := account secrets := req.GetSecrets() @@ -384,13 +391,6 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) setKeyValueInMap(parameters, containerNameField, validContainerName) } - var volumeID string - mc := metrics.NewMetricContext(blobCSIDriverName, "controller_create_volume", d.cloud.ResourceGroup, d.cloud.SubscriptionID, d.Name) - isOperationSucceeded := false - defer func() { - mc.ObserveOperationWithResult(isOperationSucceeded, VolumeID, volumeID) - }() - klog.V(2).Infof("begin to create container(%s) on account(%s) type(%s) subsID(%s) rg(%s) location(%s) size(%d)", validContainerName, accountName, storageAccountType, subsID, resourceGroup, location, requestGiB) if err := d.CreateBlobContainer(ctx, subsID, resourceGroup, accountName, validContainerName, secrets); err != nil { return nil, status.Errorf(codes.Internal, "failed to create container(%s) on account(%s) type(%s) rg(%s) location(%s) size(%d), error: %v", validContainerName, accountName, storageAccountType, resourceGroup, location, requestGiB, err)