Skip to content

Commit

Permalink
enhance: Use cancel label for ctx canceled storage op (#37468)
Browse files Browse the repository at this point in the history
Previously failed label is used for canceled storage op, which may cause
wrong alarm when user cancel load operation or etc. This PR utilizes
cancel label when such case happens.

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Nov 6, 2024
1 parent cf66fbe commit 92028b7
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions internal/storage/remote_chunk_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,11 @@ func (mcm *RemoteChunkManager) getObject(ctx context.Context, bucketName, object
if err == nil && reader != nil {
metrics.PersistentDataOpCounter.WithLabelValues(metrics.DataGetLabel, metrics.SuccessLabel).Inc()
} else {
metrics.PersistentDataOpCounter.WithLabelValues(metrics.DataGetLabel, metrics.FailLabel).Inc()
if errors.Is(err, context.Canceled) {
metrics.PersistentDataOpCounter.WithLabelValues(metrics.DataGetLabel, metrics.CancelLabel).Inc()
} else {
metrics.PersistentDataOpCounter.WithLabelValues(metrics.DataGetLabel, metrics.FailLabel).Inc()
}
}

return reader, err
Expand All @@ -354,7 +358,11 @@ func (mcm *RemoteChunkManager) putObject(ctx context.Context, bucketName, object
Observe(float64(start.ElapseSpan().Milliseconds()))
metrics.PersistentDataOpCounter.WithLabelValues(metrics.MetaPutLabel, metrics.SuccessLabel).Inc()
} else {
metrics.PersistentDataOpCounter.WithLabelValues(metrics.MetaPutLabel, metrics.FailLabel).Inc()
if errors.Is(err, context.Canceled) {
metrics.PersistentDataOpCounter.WithLabelValues(metrics.MetaPutLabel, metrics.CancelLabel).Inc()
} else {
metrics.PersistentDataOpCounter.WithLabelValues(metrics.MetaPutLabel, metrics.FailLabel).Inc()
}
}

return err
Expand All @@ -370,7 +378,11 @@ func (mcm *RemoteChunkManager) getObjectSize(ctx context.Context, bucketName, ob
Observe(float64(start.ElapseSpan().Milliseconds()))
metrics.PersistentDataOpCounter.WithLabelValues(metrics.DataStatLabel, metrics.SuccessLabel).Inc()
} else {
metrics.PersistentDataOpCounter.WithLabelValues(metrics.DataStatLabel, metrics.FailLabel).Inc()
if errors.Is(err, context.Canceled) {
metrics.PersistentDataOpCounter.WithLabelValues(metrics.DataStatLabel, metrics.CancelLabel).Inc()
} else {
metrics.PersistentDataOpCounter.WithLabelValues(metrics.DataStatLabel, metrics.FailLabel).Inc()
}
}

return info, err
Expand All @@ -386,7 +398,11 @@ func (mcm *RemoteChunkManager) removeObject(ctx context.Context, bucketName, obj
Observe(float64(start.ElapseSpan().Milliseconds()))
metrics.PersistentDataOpCounter.WithLabelValues(metrics.DataRemoveLabel, metrics.SuccessLabel).Inc()
} else {
metrics.PersistentDataOpCounter.WithLabelValues(metrics.DataRemoveLabel, metrics.FailLabel).Inc()
if errors.Is(err, context.Canceled) {
metrics.PersistentDataOpCounter.WithLabelValues(metrics.DataRemoveLabel, metrics.CancelLabel).Inc()
} else {
metrics.PersistentDataOpCounter.WithLabelValues(metrics.DataRemoveLabel, metrics.FailLabel).Inc()
}
}

return err
Expand Down

0 comments on commit 92028b7

Please sign in to comment.