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

Method logStats

rest/server_context.go:1815–1849  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

1813}
1814
1815func (sc *ServerContext) logStats(ctx context.Context) error {
1816
1817 AddGoRuntimeStats()
1818
1819 sc.logNetworkInterfaceStats(ctx)
1820
1821 if err := sc.statsContext.addGoSigarStats(); err != nil {
1822 base.WarnfCtx(ctx, "Error getting sigar based system resource stats: %v", err)
1823 }
1824
1825 if err := sc.statsContext.addNodeCpuStats(); err != nil {
1826 base.WarnfCtx(ctx, "Error getting system resource stats: %v", err)
1827 }
1828
1829 sc.updateCalculatedStats(ctx)
1830 // Create wrapper expvar map in order to add a timestamp field for logging purposes
1831 currentTime := time.Now()
1832 timestamp := currentTime.Format(time.RFC3339)
1833 wrapper := statsWrapper{
1834 Stats: []byte(base.SyncGatewayStats.String()),
1835 UnixEpochTimestamp: currentTime.Unix(),
1836 RFC3339: timestamp,
1837 }
1838
1839 marshalled, err := base.JSONMarshal(wrapper)
1840 if err != nil {
1841 return err
1842 }
1843
1844 // Marshal expvar map w/ timestamp to string and write to logs
1845 base.RecordStats(string(marshalled))
1846
1847 return sc.statsContext.collectMemoryProfile(ctx, sc.Config.Logging.LogFilePath, timestamp)
1848
1849}
1850
1851func (sc *ServerContext) logNetworkInterfaceStats(ctx context.Context) {
1852

Callers 1

startStatsLoggerMethod · 0.95

Calls 10

updateCalculatedStatsMethod · 0.95
WarnfCtxFunction · 0.92
JSONMarshalFunction · 0.92
RecordStatsFunction · 0.92
AddGoRuntimeStatsFunction · 0.85
addGoSigarStatsMethod · 0.80
addNodeCpuStatsMethod · 0.80
collectMemoryProfileMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected