collect

package
Version: v0.0.0-...-ec773da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2017 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package collect implements collect metrics data

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFoundMetrics = errors.New("not found metrics")
)

about metrics errors

Functions

This section is empty.

Types

type Collector

type Collector interface {
	// metrics accessor
	GetMetrics(string) ([]byte, error)
	GetMetricsKeys() []string

	// collect metrics functions
	Add(string, float64)
	Gauge(string, float64)
	Histogram(string, float64)
	Set(string, string)
	Snapshot(string, []string)
}

Collector is collect metrics interface

type CounterMetrics

type CounterMetrics struct {
	// contains filtered or unexported fields
}

CounterMetrics is implemented Metirics for Counter

func (*CounterMetrics) Aggregate

func (m *CounterMetrics) Aggregate() map[string]Data

Aggregate return counter key and value

func (*CounterMetrics) GetType

func (m *CounterMetrics) GetType() MetricType

GetType return MetricType

type Data

type Data interface {
	MarshalJSON() ([]byte, error)
}

Data is a metrics value

type Float

type Float struct {
	// contains filtered or unexported fields
}

Float is implemented Data

func (*Float) MarshalJSON

func (f *Float) MarshalJSON() ([]byte, error)

MarshalJSON return specific encoded json

type FloatSlice

type FloatSlice struct {
	// contains filtered or unexported fields
}

FloatSlice is used by collect metrics

type GaugeMetrics

type GaugeMetrics struct {
	// contains filtered or unexported fields
}

GaugeMetrics is implemented Metrics for Gauge

func (*GaugeMetrics) Aggregate

func (m *GaugeMetrics) Aggregate() map[string]Data

Aggregate return gauge key and value

func (*GaugeMetrics) GetType

func (m *GaugeMetrics) GetType() MetricType

GetType return MetricType

type HistogramMetrics

type HistogramMetrics struct {
	// contains filtered or unexported fields
}

HistogramMetrics is implemented Metirics for Histogram

func (*HistogramMetrics) Aggregate

func (m *HistogramMetrics) Aggregate() map[string]Data

Aggregate returns aggregated histogram metrics

func (*HistogramMetrics) GetType

func (m *HistogramMetrics) GetType() MetricType

GetType return MetricType

func (*HistogramMetrics) MarshalJSONWithOrder

func (m *HistogramMetrics) MarshalJSONWithOrder() ([]byte, error)

MarshalJSONWithOrder return keeped order json

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map is used by collect metrics

type MetricType

type MetricType int

MetricType is metric types

const (
	TypeCounter MetricType
	TypeGauge
	TypeHistogram
	TypeSet
	TypeSnapshot
)

Enum of MetricType

func (MetricType) String

func (m MetricType) String() string

type Metrics

type Metrics interface {
	Aggregate() map[string]Data
	GetType() MetricType
}

Metrics is a metrics key and value

type SetMetrics

type SetMetrics struct {
	// contains filtered or unexported fields
}

SetMetrics is implemented Metrics for Set

func (*SetMetrics) Aggregate

func (m *SetMetrics) Aggregate() map[string]Data

Aggregate return sorted sort key and value

func (*SetMetrics) GetType

func (m *SetMetrics) GetType() MetricType

GetType return MetricType

type SimpleCollector

type SimpleCollector struct {
	// contains filtered or unexported fields
}

SimpleCollector is implemented Collector

func NewSimpleCollector

func NewSimpleCollector() *SimpleCollector

NewSimpleCollector return new SimpleCollector

func (*SimpleCollector) Add

func (c *SimpleCollector) Add(key string, delta float64)

Add add count for CounterMetrics

func (*SimpleCollector) Gauge

func (c *SimpleCollector) Gauge(key string, delta float64)

Gauge set metrics for GaugeMetrics

func (*SimpleCollector) GetMetrics

func (c *SimpleCollector) GetMetrics(key string) ([]byte, error)

GetMetrics returns json from encoded metrics

func (*SimpleCollector) GetMetricsKeys

func (c *SimpleCollector) GetMetricsKeys() []string

GetMetricsKeys returns keeps metrics keys

func (*SimpleCollector) Histogram

func (c *SimpleCollector) Histogram(key string, delta float64)

Histogram add metrics for Histogram

func (*SimpleCollector) Set

func (c *SimpleCollector) Set(key string, delta string)

Set add metrics for Set

func (*SimpleCollector) Snapshot

func (c *SimpleCollector) Snapshot(key string, deltas []string)

Snapshot add metrics for Snapshot

type SnapshotMetrics

type SnapshotMetrics struct {
	// contains filtered or unexported fields
}

SnapshotMetrics is implemented Metrics for Snapshot

func (*SnapshotMetrics) Aggregate

func (m *SnapshotMetrics) Aggregate() map[string]Data

Aggregate return sorted sort key and value

func (*SnapshotMetrics) GetType

func (m *SnapshotMetrics) GetType() MetricType

GetType return MetricType

type StringSlice

type StringSlice struct {
	// contains filtered or unexported fields
}

StringSlice is implemented Data

func (*StringSlice) MarshalJSON

func (s *StringSlice) MarshalJSON() ([]byte, error)

MarshalJSON return specific encoded json

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL