MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / AddGoRuntimeStats

Function AddGoRuntimeStats

rest/stats_context.go:225–259  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

223}
224
225func AddGoRuntimeStats() {
226 // Num goroutines
227 numGoroutine := runtime.NumGoroutine()
228
229 base.SyncGatewayStats.GlobalStats.ResourceUtilizationStats().NumGoroutines.Set(int64(numGoroutine))
230 base.SyncGatewayStats.GlobalStats.ResourceUtilizationStats().GoroutinesHighWatermark.Set(int64(goroutineHighwaterMark(uint64(numGoroutine))))
231
232 // Read memstats (relatively expensive)
233 memstats := runtime.MemStats{}
234 runtime.ReadMemStats(&memstats)
235
236 // Sys
237 base.SyncGatewayStats.GlobalStats.ResourceUtilizationStats().GoMemstatsSys.Set(int64(memstats.Sys))
238
239 // HeapAlloc
240 base.SyncGatewayStats.GlobalStats.ResourceUtilizationStats().GoMemstatsHeapAlloc.Set(int64(memstats.HeapAlloc))
241
242 // HeapIdle
243 base.SyncGatewayStats.GlobalStats.ResourceUtilizationStats().GoMemstatsHeapIdle.Set(int64(memstats.HeapIdle))
244
245 // HeapInuse
246 base.SyncGatewayStats.GlobalStats.ResourceUtilizationStats().GoMemstatsHeapInUse.Set(int64(memstats.HeapInuse))
247
248 // HeapReleased
249 base.SyncGatewayStats.GlobalStats.ResourceUtilizationStats().GoMemstatsHeapReleased.Set(int64(memstats.HeapReleased))
250
251 // StackInuse
252 base.SyncGatewayStats.GlobalStats.ResourceUtilizationStats().GoMemstatsStackInUse.Set(int64(memstats.StackInuse))
253
254 // StackSys
255 base.SyncGatewayStats.GlobalStats.ResourceUtilizationStats().GoMemstatsStackSys.Set(int64(memstats.StackSys))
256
257 // PauseTotalNs
258 base.SyncGatewayStats.GlobalStats.ResourceUtilizationStats().GoMemstatsPauseTotalNS.Set(int64(memstats.PauseTotalNs))
259}
260
261// Record Goroutines high watermark into expvars
262func goroutineHighwaterMark(numGoroutines uint64) (maxGoroutinesSeen uint64) {

Callers 2

logStatsMethod · 0.85
TestMemoryProfileFunction · 0.85

Calls 3

goroutineHighwaterMarkFunction · 0.85
SetMethod · 0.45

Tested by 1

TestMemoryProfileFunction · 0.68