Skip to content

Commit

Permalink
Merge pull request #1976 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…1973-to-release-1.27

[release-1.27] chore: refine create-volume metrics
  • Loading branch information
k8s-ci-robot authored Sep 25, 2023
2 parents 85b621b + 7df0096 commit 3a35431
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/azuredisk/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
if strings.EqualFold(diskParams.WriteAcceleratorEnabled, consts.TrueValue) {
diskParams.Tags[azure.WriteAcceleratorEnabled] = consts.TrueValue
}
sourceID := ""
sourceType := ""
var sourceID, sourceType string
metricsRequest := "controller_create_volume"
content := req.GetVolumeContentSource()
if content != nil {
if content.GetSnapshot() != nil {
Expand All @@ -213,6 +213,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
},
},
}
metricsRequest = "controller_create_volume_from_snapshot"
} else {
sourceID = content.GetVolume().GetVolumeId()
sourceType = consts.SourceVolume
Expand All @@ -227,6 +228,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
if sourceGiB, _ := d.GetSourceDiskSize(ctx, subsID, diskParams.ResourceGroup, path.Base(sourceID), 0, consts.SourceDiskSearchMaxDepth); sourceGiB != nil && *sourceGiB < int32(requestGiB) {
diskParams.VolumeContext[consts.ResizeRequired] = strconv.FormatBool(true)
}
metricsRequest = "controller_create_volume_from_volume"
}
}

Expand Down Expand Up @@ -270,7 +272,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
}

var diskURI string
mc := metrics.NewMetricContext(consts.AzureDiskCSIDriverName, "controller_create_volume", d.cloud.ResourceGroup, d.cloud.SubscriptionID, d.Name)
mc := metrics.NewMetricContext(consts.AzureDiskCSIDriverName, metricsRequest, d.cloud.ResourceGroup, d.cloud.SubscriptionID, d.Name)
isOperationSucceeded := false
defer func() {
mc.ObserveOperationWithResult(isOperationSucceeded, consts.VolumeID, diskURI)
Expand Down

0 comments on commit 3a35431

Please sign in to comment.