Ejemplo n.º 1
0
func (p *pstoreHandlerType) RegisterMetrics() (err error) {
	var attributes pstore.ConsumerAttributes
	p.consumer.Attributes(&attributes)
	var data pstore.ConsumerMetrics
	var visitorData visitorMetricsType
	metricsStore := p.ConsumerMetricsStore()
	visitorMetricsStore := p.visitorMetricsStore
	group := tricorder.NewGroup()
	group.RegisterUpdateFunc(
		func() time.Time {
			metricsStore.Metrics(&data)
			visitorMetricsStore.Metrics(&visitorData)
			return time.Now()
		})
	if err = tricorder.RegisterMetric(
		fmt.Sprintf("writer/%s/totalTimeSpent", p.Name()),
		p.totalTimeSpentDist,
		units.Second,
		"total time spent per sweep"); err != nil {
		return
	}
	if err = tricorder.RegisterMetric(
		fmt.Sprintf("writer/%s/writeTimePerMetric", p.Name()),
		p.perMetricWriteTimes,
		units.Millisecond,
		"Time spent writing each metric"); err != nil {
		return
	}
	if err = tricorder.RegisterMetric(
		fmt.Sprintf("writer/%s/maxRecordsPerSecond", p.Name()),
		attributes.TotalRecordsPerSecond,
		units.None,
		"Max records per second to write. 0 means unlimited"); err != nil {
		return
	}
	if err = tricorder.RegisterMetric(
		fmt.Sprintf("writer/%s/concurrency", p.Name()),
		&attributes.Concurrency,
		units.None,
		"Number of writing goroutines"); err != nil {
		return
	}
	if err = tricorder.RegisterMetric(
		fmt.Sprintf("writer/%s/batchSize", p.Name()),
		&attributes.BatchSize,
		units.None,
		"This many records written each time"); err != nil {
		return
	}
	if err = tricorder.RegisterMetric(
		fmt.Sprintf("writer/%s/rollUpSpan", p.Name()),
		&attributes.RollUpSpan,
		units.None,
		"Time period length for rolled up values. 0 means no roll up."); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		fmt.Sprintf("writer/%s/valuesWritten", p.Name()),
		&data.ValuesWritten,
		group,
		units.None,
		"Number of values written to persistent storage"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		fmt.Sprintf("writer/%s/valuesNotWritten", p.Name()),
		&data.ValuesNotWritten,
		group,
		units.None,
		"Number of values not written to persistent storage"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		fmt.Sprintf("writer/%s/timeLeft", p.Name()),
		&visitorData.TimeLeft,
		group,
		units.None,
		"approximate time writer is behind"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		fmt.Sprintf("writer/%s/blocked", p.Name()),
		&visitorData.Blocked,
		group,
		units.None,
		"true if writer is awaiting a lease"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		fmt.Sprintf("writer/%s/writeAttempts", p.Name()),
		&data.WriteAttempts,
		group,
		units.None,
		"Number of attempts to write to persistent storage"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		fmt.Sprintf("writer/%s/successfulWrites", p.Name()),
		&data.SuccessfulWrites,
		group,
		units.None,
		"Number of successful writes to persistent storage"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		fmt.Sprintf("writer/%s/successfulWriteRatio", p.Name()),
		data.SuccessfulWriteRatio,
		group,
		units.None,
		"Ratio of successful writes to write attempts"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		fmt.Sprintf("writer/%s/lastWriteError", p.Name()),
		&data.LastWriteError,
		group,
		units.None,
		"Last write error"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		fmt.Sprintf("writer/%s/lastWriteErrorTime", p.Name()),
		&data.LastWriteErrorTS,
		group,
		units.None,
		"Time of last write error"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		fmt.Sprintf("writer/%s/lastSuccessfulWrite", p.Name()),
		&data.LastSuccessfulWriteTS,
		group,
		units.None,
		"Time of last successful write"); err != nil {
		return
	}
	return
}
Ejemplo n.º 2
0
// RegisterMetrics registers the memory manager metrics
func (m *memoryManagerType) RegisterMetrics() (err error) {
	var data memoryManagerMetricsType
	group := tricorder.NewGroup()
	group.RegisterUpdateFunc(
		func() time.Time {
			m.Metrics(&data)
			return time.Now()
		})
	if err = tricorder.RegisterMetricInGroup(
		"/proc/memory-manager/alloc-bytes-needed-for-gc",
		&data.AllocBytesNeededForGC,
		group,
		units.Byte,
		"Number of allocated bytes needed to trigger GC"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		"/proc/memory-manager/largest-alloc-bytes-needed-for-gc",
		&data.LargestAllocBytesNeededForGC,
		group,
		units.Byte,
		"Number of allocated bytes needed to trigger GC"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		"/proc/memory-manager/inspected-cycle-count",
		&data.InspectedCycleCount,
		group,
		units.None,
		"Number of gc cycles inspected"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		"/proc/memory-manager/total-cycle-count",
		&data.TotalCycleCount,
		group,
		units.None,
		"Number of total gc cycles"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		"/proc/memory-manager/stw-gc-count",
		&data.STWGCCount,
		group,
		units.None,
		"Number of stop the world GCs"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		"/proc/memory-manager/no-expand-count",
		&data.NoExpandCount,
		group,
		units.None,
		"Inspected cycle counts where we disabled expanding"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		"/proc/memory-manager/page-free-bytes",
		&data.PageFreeInBytes,
		group,
		units.Byte,
		"Total number of pages freed in bytes"); err != nil {
		return
	}
	if err = tricorder.RegisterMetricInGroup(
		"/proc/memory-manager/page-free-count",
		&data.PageFreeCount,
		group,
		units.None,
		"Number of times pages freed"); err != nil {
		return
	}
	if err = tricorder.RegisterMetric(
		"proc/memory-manager/hard-limit",
		&m.hardLimit,
		units.Byte,
		"Target memory usage"); err != nil {
		return
	}
	if err = tricorder.RegisterMetric(
		"proc/memory-manager/high-water-mark",
		&m.highWaterMark,
		units.Byte,
		"Memory usage that triggers a GC"); err != nil {
		return
	}
	if err = tricorder.RegisterMetric(
		"proc/memory-manager/low-water-mark",
		&m.lowWaterMark,
		units.Byte,
		"Desired memory usage after GC happens"); err != nil {
		return
	}
	if err = tricorder.RegisterMetric(
		"proc/memory-manager/gc-percent",
		&m.gcPercent,
		units.None,
		"GC percentage"); err != nil {
		return
	}
	return
}