Exemple #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
}
Exemple #2
0
func (s *pageQueueType) RegisterMetrics(d *tricorder.DirectorySpec) (
	err error) {
	var queueStats btreepq.PageQueueStats
	queueGroup := tricorder.NewGroup()
	queueGroup.RegisterUpdateFunc(func() time.Time {
		s.PageQueueStats(&queueStats)
		return time.Now()
	})
	if err = d.RegisterMetricInGroup(
		"/highPriorityCount",
		&queueStats.HighPriorityCount,
		queueGroup,
		units.None,
		"Number of pages in high priority queue"); err != nil {
		return
	}
	if err = d.RegisterMetricInGroup(
		"/lowPriorityCount",
		&queueStats.LowPriorityCount,
		queueGroup,
		units.None,
		"Number of pages in low priority queue"); err != nil {
		return
	}
	if err = d.RegisterMetricInGroup(
		"/totalPages",
		queueStats.TotalCount,
		queueGroup,
		units.None,
		"Total number of pages."); err != nil {
		return
	}
	if err = d.RegisterMetricInGroup(
		"/nextLowPrioritySeqNo",
		&queueStats.NextLowPrioritySeqNo,
		queueGroup,
		units.None,
		"Next seq no in low priority queue, 0 if empty"); err != nil {
		return
	}
	if err = d.RegisterMetricInGroup(
		"/nextHighPrioritySeqNo",
		&queueStats.NextHighPrioritySeqNo,
		queueGroup,
		units.None,
		"Next seq no in high priority queue, 0 if empty"); err != nil {
		return
	}
	if err = d.RegisterMetricInGroup(
		"/endSeqNo",
		&queueStats.EndSeqNo,
		queueGroup,
		units.None,
		"All seq no smaller than this. Marks end of both queues."); err != nil {
		return
	}
	if err = d.RegisterMetricInGroup(
		"/highPriorityRatio",
		queueStats.HighPriorityRatio,
		queueGroup,
		units.None,
		"High priority page ratio"); err != nil {
		return
	}

	if err = d.RegisterMetric(
		"/expanding",
		s.IsExpanding,
		units.None,
		"Is page queue expanding."); err != nil {
		return
	}
	if err = d.RegisterMetric(
		"/maxValuesPerPage",
		&s.valueCountPerPage,
		units.None,
		"Maximum number ofvalues that can fit in a page."); err != nil {
		return
	}
	if err = d.RegisterMetric(
		"/inactiveThreshhold",
		&s.inactiveThreshhold,
		units.None,
		"The ratio of inactive pages needed before they are reclaimed first"); err != nil {
		return
	}
	if err = d.RegisterMetric(
		"/btreeDegree",
		&s.degree,
		units.None,
		"The degree of the btrees in the queue"); err != nil {
		return
	}
	return
}
Exemple #3
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
}
Exemple #4
0
func (s *Store) registerMetrics(d *tricorder.DirectorySpec) (err error) {
	if err = s.supplier.RegisterMetrics(d); err != nil {
		return
	}
	// Allow this store instance to be GCed
	maxValuesPerPage := s.supplier.MaxValuesPerPage()
	metrics := s.metrics

	if err = d.RegisterMetric(
		"/pagesPerMetric",
		metrics.PagesPerMetricDist,
		units.None,
		"Number of pages used per metric"); err != nil {
		return
	}
	var primitiveMetrics storePrimitiveMetricsType
	storeGroup := tricorder.NewGroup()
	storeGroup.RegisterUpdateFunc(func() time.Time {
		metrics.Metrics(&primitiveMetrics)
		return time.Now()
	})
	if err = d.RegisterMetricInGroup(
		"/pageUtilization",
		func() float64 {
			metricValueCount := primitiveMetrics.UniqueMetricValueCount
			pagesInUseCount := metrics.PagesPerMetricDist.Sum()
			metricCount := metrics.PagesPerMetricDist.Count()
			extraValueCount := float64(metricValueCount) - float64(metricCount)
			return extraValueCount / pagesInUseCount / float64(maxValuesPerPage)
		},
		storeGroup,
		units.None,
		"Page utilization 0.0 - 1.0"); err != nil {
		return
	}
	if err = d.RegisterMetricInGroup(
		"/metricValueCount",
		&primitiveMetrics.UniqueMetricValueCount,
		storeGroup,
		units.None,
		"Number of unique metrics values"); err != nil {
		return
	}
	if err = d.RegisterMetricInGroup(
		"/timeSpan",
		primitiveMetrics.TimeSpan,
		storeGroup,
		units.Second,
		"Span of time in store"); err != nil {
		return
	}
	if err = d.RegisterMetricInGroup(
		"/valuePageCount",
		metrics.PagesPerMetricDist.Sum,
		storeGroup,
		units.None,
		"Number of pages used for values."); err != nil {
		return
	}
	if err = d.RegisterMetricInGroup(
		"/timestampPageCount",
		&primitiveMetrics.TimeStampPageCount,
		storeGroup,
		units.None,
		"Number of pages used for timestamps."); err != nil {
		return
	}
	if err = d.RegisterMetricInGroup(
		"/totalPagesInUseCount",
		func() int64 {
			return primitiveMetrics.TimeStampPageCount + int64(metrics.PagesPerMetricDist.Sum())
		},
		storeGroup,
		units.None,
		"Total number of pages used."); err != nil {
		return
	}
	return
}