MCPcopy
hub / github.com/uber/aresdb / reportAllocatedMemory

Function reportAllocatedMemory

query/device_allocator.go:133–155  ·  view source on GitHub ↗
(deviceCount int, da deviceAllocator)

Source from the content-addressed store, hash-verified

131}
132
133func reportAllocatedMemory(deviceCount int, da deviceAllocator) {
134 // getAllocatedMemory may panic, therefore we should recover here
135 defer func() {
136 if r := recover(); r != nil {
137 var err error
138 switch x := r.(type) {
139 case string:
140 err = utils.StackError(nil, x)
141 case error:
142 err = utils.StackError(x, "Panic happens when reporting allocated memory")
143 default:
144 err = utils.StackError(nil, "Panic happens when reporting allocated memory %v", x)
145 }
146 utils.GetLogger().With("err", err).Error("Failed to report allocated memory")
147 }
148 }()
149
150 for device := 0; device < deviceCount; device++ {
151 utils.GetRootReporter().GetChildGauge(map[string]string{
152 "device": strconv.Itoa(device),
153 }, utils.AllocatedDeviceMemory).Update(float64(da.getAllocatedMemory(device)))
154 }
155}
156
157// newDeviceAllocator returns a new device allocator instances.
158func newDeviceAllocator() deviceAllocator {

Callers 2

newDeviceAllocatorFunction · 0.85

Calls 8

StackErrorFunction · 0.92
GetLoggerFunction · 0.92
GetRootReporterFunction · 0.92
GetChildGaugeMethod · 0.80
ErrorMethod · 0.65
WithMethod · 0.65
UpdateMethod · 0.65
getAllocatedMemoryMethod · 0.65

Tested by

no test coverage detected