Skip to content

Commit

Permalink
Merge pull request #1023 from andyzhangx/refine-create-volume-metrics
Browse files Browse the repository at this point in the history
fix: refine create volume metrics
  • Loading branch information
andyzhangx authored Sep 26, 2023
2 parents bef18b3 + 0f95949 commit b28c862
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/blob/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,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()
Expand Down Expand Up @@ -380,13 +387,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)
Expand Down

0 comments on commit b28c862

Please sign in to comment.