MCPcopy Create free account
hub / github.com/flant/shell-operator / updateCompactionMetrics

Method updateCompactionMetrics

pkg/task/queue/task_queue.go:717–745  ·  view source on GitHub ↗

updateCompactionMetrics counts tasks by hook and updates metrics

()

Source from the content-addressed store, hash-verified

715
716// updateCompactionMetrics counts tasks by hook and updates metrics
717func (q *TaskQueue) updateCompactionMetrics() {
718 hookCounts := make(map[string]uint)
719
720 // Use IterateSnapshot to avoid holding locks during iteration
721 q.IterateSnapshot(func(t task.Task) {
722 // Only count compactable task types
723 if _, ok := q.compactableTypes[t.GetType()]; !ok {
724 return
725 }
726
727 metadata := t.GetMetadata()
728 if isNil(metadata) {
729 return
730 }
731
732 hookNameAccessor, ok := metadata.(task_metadata.HookNameAccessor)
733 if !ok {
734 return
735 }
736
737 hookName := hookNameAccessor.GetHookName()
738 if hookName != "" {
739 hookCounts[hookName]++
740 }
741 })
742
743 // Update metrics based on current state
744 q.queueTasksCounter.UpdateHookMetricsFromSnapshot(hookCounts)
745}
746
747// lazydebug evaluates args only if debug log is enabled.
748// It is used to avoid unnecessary allocations when logging is disabled.

Callers 1

Calls 6

IterateSnapshotMethod · 0.95
isNilFunction · 0.85
GetTypeMethod · 0.65
GetMetadataMethod · 0.65
GetHookNameMethod · 0.65

Tested by

no test coverage detected