예제 #1
0
파일: gc.go 프로젝트: neocortical/gonr
func addGCMetrics(p *newrelic.Plugin) {
	numGC := metrics.NewMeter()
	pauseDur := metrics.NewMeter()
	pauseTime := metrics.NewHistogram(metrics.NewExpDecaySample(10000, 0.015))
	gcr := &gcReader{
		sampleRate: time.Second * 10,
		numGC:      numGC,
		pauseDur:   pauseDur,
		pauseTime:  pauseTime,
	}
	gcr.Run()

	nrmetrics.AddMeterMetric(p, numGC, nrmetrics.MetricConfig{Name: "GC/GC Pauses Per Second", Unit: "pauses", Rate1: true, Rate5: true, Rate15: true})
	nrmetrics.AddMeterMetric(p, pauseDur, nrmetrics.MetricConfig{Name: "GC/GC Pause Time Per Second", Unit: "nanoseconds", Rate1: true, Rate5: true, Rate15: true})
	nrmetrics.AddHistogramMetric(p, pauseTime, nrmetrics.MetricConfig{
		Name:        "GC/GC Time Per Pause",
		Unit:        "pauses",
		Duration:    time.Microsecond,
		Mean:        true,
		Percentiles: []float64{0.5, 0.75, 0.9, 0.99, 0.999},
	})
}
예제 #2
0
파일: memory.go 프로젝트: neocortical/gonr
func addMemoryMetrics(p *newrelic.Plugin) {
	allocInUse := metrics.NewGauge()
	allocTotal := metrics.NewGauge()
	sys := metrics.NewGauge()

	pointerLookups := metrics.NewMeter()
	mallocs := metrics.NewMeter()
	frees := metrics.NewMeter()

	allocHeap := metrics.NewGauge()
	heapSys := metrics.NewGauge()
	heapIdle := metrics.NewGauge()
	heapInUse := metrics.NewGauge()
	heapReleased := metrics.NewGauge()
	heapObjects := metrics.NewGauge()

	stackInUse := metrics.NewGauge()
	stackSys := metrics.NewGauge()

	mspanInUse := metrics.NewGauge()
	mspanSys := metrics.NewGauge()
	mcacheInUse := metrics.NewGauge()
	mcacheSys := metrics.NewGauge()
	buckHashSys := metrics.NewGauge()
	gcSys := metrics.NewGauge()
	otherSys := metrics.NewGauge()

	mr := &memReader{
		sampleRate:     time.Minute,
		allocInUse:     allocInUse,
		allocTotal:     allocTotal,
		pointerLookups: pointerLookups,
		mallocs:        mallocs,
		frees:          frees,
		allocHeap:      allocHeap,
		heapSys:        heapSys,
		heapIdle:       heapIdle,
		heapInUse:      heapInUse,
		heapReleased:   heapReleased,
		heapObjects:    heapObjects,
		stackInUse:     stackInUse,
		stackSys:       stackSys,
		mspanInUse:     mspanInUse,
		mspanSys:       mspanSys,
		mcacheInUse:    mcacheInUse,
		mcacheSys:      mcacheSys,
		buckHashSys:    buckHashSys,
		gcSys:          gcSys,
		otherSys:       otherSys,
	}
	mr.Run()

	nrmetrics.AddGaugeMetric(p, allocTotal, nrmetrics.MetricConfig{Name: "Memory/Summary/Allocated Over Time", Unit: "bytes", Value: true})

	nrmetrics.AddGaugeMetric(p, sys, nrmetrics.MetricConfig{Name: "Memory/Summary/System/Total", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, heapSys, nrmetrics.MetricConfig{Name: "Memory/System/Heap", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, stackSys, nrmetrics.MetricConfig{Name: "Memory/System/Stack", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, mspanSys, nrmetrics.MetricConfig{Name: "Memory/System/MSpan", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, mcacheSys, nrmetrics.MetricConfig{Name: "Memory/System/MCache", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, buckHashSys, nrmetrics.MetricConfig{Name: "Memory/System/BuckHash", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, gcSys, nrmetrics.MetricConfig{Name: "Memory/System/GC", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, otherSys, nrmetrics.MetricConfig{Name: "Memory/System/Other", Unit: "bytes", Value: true})

	nrmetrics.AddGaugeMetric(p, allocInUse, nrmetrics.MetricConfig{Name: "Memory/Summary/In Use/Total", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, heapInUse, nrmetrics.MetricConfig{Name: "Memory/In Use/Heap", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, stackInUse, nrmetrics.MetricConfig{Name: "Memory/In Use/Stack", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, mspanInUse, nrmetrics.MetricConfig{Name: "Memory/In Use/MSpan", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, mcacheInUse, nrmetrics.MetricConfig{Name: "Memory/In Use/MCache", Unit: "bytes", Value: true})

	nrmetrics.AddGaugeMetric(p, allocHeap, nrmetrics.MetricConfig{Name: "Memory/Heap/Allocated", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, heapIdle, nrmetrics.MetricConfig{Name: "Memory/Heap/Idle", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, heapInUse, nrmetrics.MetricConfig{Name: "Memory/Heap/In Use", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, heapReleased, nrmetrics.MetricConfig{Name: "Memory/Heap/Released", Unit: "bytes", Value: true})

	nrmetrics.AddGaugeMetric(p, heapObjects, nrmetrics.MetricConfig{Name: "Memory/Events/Allocated Heap Objects", Unit: "objects", Value: true})

	nrmetrics.AddMeterMetric(p, pointerLookups, nrmetrics.MetricConfig{
		Name:   "Memory/Events/Pointer Lookups",
		Unit:   "lookups",
		Rate1:  true,
		Rate5:  true,
		Rate15: true,
	})
	nrmetrics.AddMeterMetric(p, mallocs, nrmetrics.MetricConfig{
		Name:   "Memory/Events/Mallocs",
		Unit:   "mallocs",
		Rate1:  true,
		Rate5:  true,
		Rate15: true,
	})
	nrmetrics.AddMeterMetric(p, frees, nrmetrics.MetricConfig{
		Name:   "Memory/Events/Frees",
		Unit:   "frees",
		Rate1:  true,
		Rate5:  true,
		Rate15: true,
	})
}