MCPcopy Index your code
hub / github.com/flant/shell-operator / MeasureActionTime

Method MeasureActionTime

pkg/task/queue/task_queue.go:251–268  ·  view source on GitHub ↗

MeasureActionTime is a helper to measure execution time of queue's actions

(action string)

Source from the content-addressed store, hash-verified

249
250// MeasureActionTime is a helper to measure execution time of queue's actions
251func (q *TaskQueue) MeasureActionTime(action string) func() {
252 if q.metricStorage == nil {
253 return func() {}
254 }
255
256 q.measureActionFnOnce.Do(func() {
257 // TODO: remove this metrics switch
258 if os.Getenv("QUEUE_ACTIONS_METRICS") == "no" {
259 q.measureActionFn = func() {}
260 } else {
261 q.measureActionFn = measure.Duration(func(d time.Duration) {
262 q.metricStorage.HistogramObserve(metrics.TasksQueueActionDurationSeconds, d.Seconds(), map[string]string{pkg.MetricKeyQueueName: q.Name, pkg.MetricKeyQueueAction: action}, nil)
263 })
264 }
265 })
266
267 return q.measureActionFn
268}
269
270func (q *TaskQueue) GetStatus() string {
271 defer q.MeasureActionTime("GetStatus")()

Callers 14

GetStatusMethod · 0.95
LengthMethod · 0.95
AddFirstMethod · 0.95
RemoveFirstMethod · 0.95
GetFirstMethod · 0.95
AddLastMethod · 0.95
RemoveLastMethod · 0.95
GetLastMethod · 0.95
GetMethod · 0.95
AddAfterMethod · 0.95
AddBeforeMethod · 0.95
RemoveMethod · 0.95

Calls 2

DurationFunction · 0.92
HistogramObserveMethod · 0.45

Tested by

no test coverage detected