Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collect: instrumenting some basic gc stats #1267

Merged
merged 1 commit into from
Aug 20, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions collect/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ const (
descCollectAlloc = "Total number of bytes allocated and still in use by the runtime (via runtime.ReadMemStats)."
descCollectDropped = "Counter of dropped data points due to the queue being full."
descCollectGoRoutines = "Total number of goroutines that currently exist (via runtime.NumGoroutine)."
descCollectGcCpuFraction = "fraction of CPU time used by GC"
descCollectTotalGCPause = "Total GC Pause time in milliseconds"
descCollectPostBad = "Counter of HTTP POST requests where resp.StatusCode != http.StatusNoContent."
descCollectPostBatchSize = "Number of datapoints included in each batch."
descCollectPostCount = "Counter of batches sent to the server."
Expand Down Expand Up @@ -143,13 +145,25 @@ func InitChan(tsdbhost *url.URL, root string, ch chan *opentsdb.DataPoint) error
runtime.ReadMemStats(&ms)
return ms.Alloc
})
Set("collect.gc.cpu_fraction", Tags, func() interface{} {
var ms runtime.MemStats
runtime.ReadMemStats(&ms)
return ms.GCCPUFraction
})
Set("collect.gc.total_pause", Tags, func() interface{} {
var ms runtime.MemStats
runtime.ReadMemStats(&ms)
return ms.PauseTotalNs / uint64(time.Millisecond)
})
Set("collect.goroutines", Tags, func() interface{} {
return runtime.NumGoroutine()
})
AggregateMeta(metricRoot+"collect.post.batchsize", metadata.Count, descCollectPostBatchSize)
AggregateMeta(metricRoot+"collect.post.duration", metadata.MilliSecond, descCollectPostDuration)
metadata.AddMetricMeta(metricRoot+"collect.alloc", metadata.Gauge, metadata.Bytes, descCollectAlloc)
metadata.AddMetricMeta(metricRoot+"collect.goroutines", metadata.Gauge, metadata.Count, descCollectGoRoutines)
metadata.AddMetricMeta(metricRoot+"collect.gc.cpu_fraction", metadata.Gauge, metadata.Pct, descCollectGcCpuFraction)
metadata.AddMetricMeta(metricRoot+"collect.gc.total_pause", metadata.Counter, metadata.MilliSecond, descCollectTotalGCPause)
metadata.AddMetricMeta(metricRoot+"collect.post.bad_status", metadata.Counter, metadata.PerSecond, descCollectPostBad)
metadata.AddMetricMeta(metricRoot+"collect.post.count", metadata.Counter, metadata.PerSecond, descCollectPostCount)
metadata.AddMetricMeta(metricRoot+"collect.post.error", metadata.Counter, metadata.PerSecond, descCollectPostError)
Expand Down