Skip to content

Commit

Permalink
Fix lock
Browse files Browse the repository at this point in the history
Signed-off-by: Zhonghu Xu <[email protected]>
  • Loading branch information
hzxuzhonghu committed Nov 6, 2024
1 parent 0a3d5b5 commit cce43a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/telemetry/bpf_prog_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ func (m *BpfProgMetric) Run(ctx context.Context, KmeshPerfInfo *ebpf.Map) {
durations: []uint64{operationData.endTime - operationData.startTime},
operationType: operationData.operationType,
}
m.mutex.Lock()
m.updateOperationMetricCache(operationInfo, buildOperationMetricLabel(&operationData))
m.mutex.Unlock()
}
}
}
Expand All @@ -137,6 +135,8 @@ func buildOperationMetricLabel(data *operationTimeMetric) operationMetricLabels

func (m *BpfProgMetric) updateOperationMetricCache(data operationDuration, labels operationMetricLabels) {
m.mutex.Lock()
defer m.mutex.Unlock()

v, ok := m.operationMetricCache[labels]
if ok {
v.durations = append(v.durations, data.durations...)
Expand Down

0 comments on commit cce43a9

Please sign in to comment.