(ctx context.Context)
| 1813 | } |
| 1814 | |
| 1815 | func (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 | |
| 1851 | func (sc *ServerContext) logNetworkInterfaceStats(ctx context.Context) { |
| 1852 |
no test coverage detected