Skip to content

Commit

Permalink
measure branch ENI operation latency in seconds (aws#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
sushrk committed Oct 25, 2024
1 parent f09b02f commit f251598
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/provider/branch/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var (
branchProviderOperationLatency = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Name: "branch_provider_operation_latency",
Help: "Branch Provider operations latency in ms",
Help: "Branch Provider operations latency in seconds",
Objectives: map[float64]float64{0: 0, 0.5: 0.05, 0.9: 0.01, 0.99: 0.001, 1: 0},
},
[]string{operationLabel, resourceCountLabel},
Expand Down Expand Up @@ -134,9 +134,9 @@ func prometheusRegister() {
}
}

// timeSinceMs returns the time since MS from the start time
func timeSinceMs(start time.Time) float64 {
return float64(time.Since(start).Milliseconds())
// timeSinceSeconds returns the time elapsed in seconds from the start time
func timeSinceSeconds(start time.Time) float64 {
return float64(time.Since(start).Seconds())
}

// InitResources initialized the resource for the given node name. The initialized trunk ENI is stored in
Expand Down Expand Up @@ -177,7 +177,7 @@ func (b *branchENIProvider) InitResource(instance ec2.EC2Instance) error {
branchProviderOperationsErrCount.WithLabelValues("init").Inc()
return fmt.Errorf("initializing trunk, %w", err)
}
branchProviderOperationLatency.WithLabelValues(operationInitTrunk, "1").Observe(timeSinceMs(start))
branchProviderOperationLatency.WithLabelValues(operationInitTrunk, "1").Observe(timeSinceSeconds(start))

// Add the Trunk ENI to cache
if err := b.addTrunkToCache(nodeName, trunkENI); err != nil {
Expand Down Expand Up @@ -370,7 +370,7 @@ func (b *branchENIProvider) CreateAndAnnotateResources(podNamespace string, podN
}

branchProviderOperationLatency.WithLabelValues(operationCreateBranchENI, strconv.Itoa(resourceCount)).
Observe(timeSinceMs(start))
Observe(timeSinceSeconds(start))

jsonBytes, err := json.Marshal(branchENIs)
if err != nil {
Expand Down Expand Up @@ -398,7 +398,7 @@ func (b *branchENIProvider) CreateAndAnnotateResources(podNamespace string, podN
fmt.Sprintf("Allocated %s to the pod", string(jsonBytes)), v1.EventTypeNormal)

branchProviderOperationLatency.WithLabelValues(operationAnnotateBranchENI, strconv.Itoa(resourceCount)).
Observe(timeSinceMs(start))
Observe(timeSinceSeconds(start))

log.Info("created and annotated branch interface/s successfully", "branches", branchENIs)

Expand Down

0 comments on commit f251598

Please sign in to comment.