Skip to content

Commit 4957717

Browse files
tevjefsparrc
authored andcommitted
Add field for last GC pause time (#2121)
1 parent 21fac3e commit 4957717

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ in their config file.
2727
- [#2079](https://github.com/influxdata/telegraf/pull/2079): Enable setting ClientID in MQTT output.
2828
- [#2001](https://github.com/influxdata/telegraf/pull/2001): MongoDB input plugin: Improve state data.
2929
- [#2078](https://github.com/influxdata/telegraf/pull/2078): Ping input: add standard deviation field.
30+
- [#2121](https://github.com/influxdata/telegraf/pull/2121): Add GC pause metric to InfluxDB input plugin.
3031

3132
### Bugfixes
3233

plugins/inputs/influxdb/influxdb.go

+28-26
Original file line numberDiff line numberDiff line change
@@ -94,32 +94,33 @@ type point struct {
9494
}
9595

9696
type memstats struct {
97-
Alloc int64 `json:"Alloc"`
98-
TotalAlloc int64 `json:"TotalAlloc"`
99-
Sys int64 `json:"Sys"`
100-
Lookups int64 `json:"Lookups"`
101-
Mallocs int64 `json:"Mallocs"`
102-
Frees int64 `json:"Frees"`
103-
HeapAlloc int64 `json:"HeapAlloc"`
104-
HeapSys int64 `json:"HeapSys"`
105-
HeapIdle int64 `json:"HeapIdle"`
106-
HeapInuse int64 `json:"HeapInuse"`
107-
HeapReleased int64 `json:"HeapReleased"`
108-
HeapObjects int64 `json:"HeapObjects"`
109-
StackInuse int64 `json:"StackInuse"`
110-
StackSys int64 `json:"StackSys"`
111-
MSpanInuse int64 `json:"MSpanInuse"`
112-
MSpanSys int64 `json:"MSpanSys"`
113-
MCacheInuse int64 `json:"MCacheInuse"`
114-
MCacheSys int64 `json:"MCacheSys"`
115-
BuckHashSys int64 `json:"BuckHashSys"`
116-
GCSys int64 `json:"GCSys"`
117-
OtherSys int64 `json:"OtherSys"`
118-
NextGC int64 `json:"NextGC"`
119-
LastGC int64 `json:"LastGC"`
120-
PauseTotalNs int64 `json:"PauseTotalNs"`
121-
NumGC int64 `json:"NumGC"`
122-
GCCPUFraction float64 `json:"GCCPUFraction"`
97+
Alloc int64 `json:"Alloc"`
98+
TotalAlloc int64 `json:"TotalAlloc"`
99+
Sys int64 `json:"Sys"`
100+
Lookups int64 `json:"Lookups"`
101+
Mallocs int64 `json:"Mallocs"`
102+
Frees int64 `json:"Frees"`
103+
HeapAlloc int64 `json:"HeapAlloc"`
104+
HeapSys int64 `json:"HeapSys"`
105+
HeapIdle int64 `json:"HeapIdle"`
106+
HeapInuse int64 `json:"HeapInuse"`
107+
HeapReleased int64 `json:"HeapReleased"`
108+
HeapObjects int64 `json:"HeapObjects"`
109+
StackInuse int64 `json:"StackInuse"`
110+
StackSys int64 `json:"StackSys"`
111+
MSpanInuse int64 `json:"MSpanInuse"`
112+
MSpanSys int64 `json:"MSpanSys"`
113+
MCacheInuse int64 `json:"MCacheInuse"`
114+
MCacheSys int64 `json:"MCacheSys"`
115+
BuckHashSys int64 `json:"BuckHashSys"`
116+
GCSys int64 `json:"GCSys"`
117+
OtherSys int64 `json:"OtherSys"`
118+
NextGC int64 `json:"NextGC"`
119+
LastGC int64 `json:"LastGC"`
120+
PauseTotalNs int64 `json:"PauseTotalNs"`
121+
PauseNs [256]int64 `json:"PauseNs"`
122+
NumGC int64 `json:"NumGC"`
123+
GCCPUFraction float64 `json:"GCCPUFraction"`
123124
}
124125

125126
// Gathers data from a particular URL
@@ -202,6 +203,7 @@ func (i *InfluxDB) gatherURL(
202203
"next_gc": m.NextGC,
203204
"last_gc": m.LastGC,
204205
"pause_total_ns": m.PauseTotalNs,
206+
"pause_ns": m.PauseNs[(m.NumGC+255)%256],
205207
"num_gc": m.NumGC,
206208
"gcc_pu_fraction": m.GCCPUFraction,
207209
},

plugins/inputs/influxdb/influxdb_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func TestInfluxDB(t *testing.T) {
8686
"frees": int64(381008),
8787
"heap_idle": int64(15802368),
8888
"pause_total_ns": int64(5132914),
89+
"pause_ns": int64(127053),
8990
"lookups": int64(77),
9091
"heap_sys": int64(33849344),
9192
"mcache_sys": int64(16384),

0 commit comments

Comments
 (0)