metrics

package
v0.0.0-...-7b3ddb2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package metrics is a generated protocol buffer package.

It is generated from these files:

model.proto

It has these top-level messages:

LabelPair
Metadata
MetricFamily
MetricData
CounterData
CounterRateData
GaugeData
HistogramData
Bucket
Percentile

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthModel = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowModel   = fmt.Errorf("proto: integer overflow")
)
View Source
var MetricType_name = map[int32]string{
	0: "UNTYPED",
	1: "COUNTER",
	2: "COUNTERRATE",
	3: "GAUGE",
	4: "HISTOGRAM",
}
View Source
var MetricType_value = map[string]int32{
	"UNTYPED":     0,
	"COUNTER":     1,
	"COUNTERRATE": 2,
	"GAUGE":       3,
	"HISTOGRAM":   4,
}
View Source
var Unit_name = map[int32]string{
	0: "UNSET",
	1: "BYTES",
	2: "CONST",
	3: "COUNT",
	4: "NANOSECONDS",
	5: "PERCENT",
	6: "SECONDS",
}
View Source
var Unit_value = map[string]int32{
	"UNSET":       0,
	"BYTES":       1,
	"CONST":       2,
	"COUNT":       3,
	"NANOSECONDS": 4,
	"PERCENT":     5,
	"SECONDS":     6,
}

Functions

func ExportedLabel

func ExportedLabel(name string) string

ExportedLabel generates a valid metric label.

func ExportedName

func ExportedName(name string) string

ExportedName generates a valid metric name.

Types

type Bucket

type Bucket struct {
	CumulativeCount uint64  `protobuf:"varint,1,opt,name=cumulative_count,json=cumulativeCount,proto3" json:"cumulative_count,omitempty"`
	UpperBound      float64 `protobuf:"fixed64,2,opt,name=upper_bound,json=upperBound,proto3" json:"upper_bound,omitempty"`
}

func (*Bucket) Descriptor

func (*Bucket) Descriptor() ([]byte, []int)

func (*Bucket) Marshal

func (m *Bucket) Marshal() (dAtA []byte, err error)

func (*Bucket) MarshalTo

func (m *Bucket) MarshalTo(dAtA []byte) (int, error)

func (*Bucket) ProtoMessage

func (*Bucket) ProtoMessage()

func (*Bucket) Reset

func (m *Bucket) Reset()

func (*Bucket) Size

func (m *Bucket) Size() (n int)

func (*Bucket) String

func (m *Bucket) String() string

func (*Bucket) Unmarshal

func (m *Bucket) Unmarshal(dAtA []byte) error

type CounterData

type CounterData struct {
	Value float64 `protobuf:"fixed64,1,opt,name=value,proto3" json:"value,omitempty"`
}

func (*CounterData) Descriptor

func (*CounterData) Descriptor() ([]byte, []int)

func (*CounterData) Marshal

func (m *CounterData) Marshal() (dAtA []byte, err error)

func (*CounterData) MarshalTo

func (m *CounterData) MarshalTo(dAtA []byte) (int, error)

func (*CounterData) ProtoMessage

func (*CounterData) ProtoMessage()

func (*CounterData) Reset

func (m *CounterData) Reset()

func (*CounterData) Size

func (m *CounterData) Size() (n int)

func (*CounterData) String

func (m *CounterData) String() string

func (*CounterData) Unmarshal

func (m *CounterData) Unmarshal(dAtA []byte) error

type CounterRateData

type CounterRateData struct {
	TotalValue  float64 `protobuf:"fixed64,1,opt,name=total_value,json=totalValue,proto3" json:"total_value,omitempty"`
	WindowValue float64 `protobuf:"fixed64,2,opt,name=window_value,json=windowValue,proto3" json:"window_value,omitempty"`
	AvgValue    float64 `protobuf:"fixed64,3,opt,name=avg_value,json=avgValue,proto3" json:"avg_value,omitempty"`
}

func (*CounterRateData) Descriptor

func (*CounterRateData) Descriptor() ([]byte, []int)

func (*CounterRateData) Marshal

func (m *CounterRateData) Marshal() (dAtA []byte, err error)

func (*CounterRateData) MarshalTo

func (m *CounterRateData) MarshalTo(dAtA []byte) (int, error)

func (*CounterRateData) ProtoMessage

func (*CounterRateData) ProtoMessage()

func (*CounterRateData) Reset

func (m *CounterRateData) Reset()

func (*CounterRateData) Size

func (m *CounterRateData) Size() (n int)

func (*CounterRateData) String

func (m *CounterRateData) String() string

func (*CounterRateData) Unmarshal

func (m *CounterRateData) Unmarshal(dAtA []byte) error

type ExportTimer

type ExportTimer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewExportTimer

func NewExportTimer(ctx context.Context, interval time.Duration) *ExportTimer

func (*ExportTimer) AddExporter

func (t *ExportTimer) AddExporter(exporter ...Exporter)

func (*ExportTimer) AddRegistry

func (t *ExportTimer) AddRegistry(registry ...*Registry)

func (*ExportTimer) Start

func (t *ExportTimer) Start() error

type Exporter

type Exporter interface {
	DumpRegistry([]*Registry)
	GetMetric() map[string]*MetricFamily
	PrintText(io.Writer) error
}

Exporter export metrics in Registry.

type GaugeData

type GaugeData struct {
	Value float64 `protobuf:"fixed64,1,opt,name=value,proto3" json:"value,omitempty"`
}

func (*GaugeData) Descriptor

func (*GaugeData) Descriptor() ([]byte, []int)

func (*GaugeData) Marshal

func (m *GaugeData) Marshal() (dAtA []byte, err error)

func (*GaugeData) MarshalTo

func (m *GaugeData) MarshalTo(dAtA []byte) (int, error)

func (*GaugeData) ProtoMessage

func (*GaugeData) ProtoMessage()

func (*GaugeData) Reset

func (m *GaugeData) Reset()

func (*GaugeData) Size

func (m *GaugeData) Size() (n int)

func (*GaugeData) String

func (m *GaugeData) String() string

func (*GaugeData) Unmarshal

func (m *GaugeData) Unmarshal(dAtA []byte) error

type HistogramData

type HistogramData struct {
	SampleCount uint64       `protobuf:"varint,1,opt,name=sample_count,json=sampleCount,proto3" json:"sample_count,omitempty"`
	SampleSum   float64      `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum,proto3" json:"sample_sum,omitempty"`
	Buckets     []Bucket     `protobuf:"bytes,3,rep,name=buckets" json:"buckets"`
	Pts         []Percentile `protobuf:"bytes,4,rep,name=pts" json:"pts"`
}

func (*HistogramData) Descriptor

func (*HistogramData) Descriptor() ([]byte, []int)

func (*HistogramData) Marshal

func (m *HistogramData) Marshal() (dAtA []byte, err error)

func (*HistogramData) MarshalTo

func (m *HistogramData) MarshalTo(dAtA []byte) (int, error)

func (*HistogramData) ProtoMessage

func (*HistogramData) ProtoMessage()

func (*HistogramData) Reset

func (m *HistogramData) Reset()

func (*HistogramData) Size

func (m *HistogramData) Size() (n int)

func (*HistogramData) String

func (m *HistogramData) String() string

func (*HistogramData) Unmarshal

func (m *HistogramData) Unmarshal(dAtA []byte) error

type LabelPair

type LabelPair struct {
	Name  string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
}

func (*LabelPair) Descriptor

func (*LabelPair) Descriptor() ([]byte, []int)

func (*LabelPair) Marshal

func (m *LabelPair) Marshal() (dAtA []byte, err error)

func (*LabelPair) MarshalTo

func (m *LabelPair) MarshalTo(dAtA []byte) (int, error)

func (*LabelPair) ProtoMessage

func (*LabelPair) ProtoMessage()

func (*LabelPair) Reset

func (m *LabelPair) Reset()

func (*LabelPair) Size

func (m *LabelPair) Size() (n int)

func (*LabelPair) String

func (m *LabelPair) String() string

func (*LabelPair) Unmarshal

func (m *LabelPair) Unmarshal(dAtA []byte) error

type Metadata

type Metadata struct {
	Name   string      `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Help   string      `protobuf:"bytes,2,opt,name=help,proto3" json:"help,omitempty"`
	Unit   Unit        `protobuf:"varint,3,opt,name=unit,proto3,enum=Unit" json:"unit,omitempty"`
	Labels []LabelPair `protobuf:"bytes,4,rep,name=labels" json:"labels"`
}

Metadata holds metadata about a metric.

func (*Metadata) AddLabel

func (m *Metadata) AddLabel(name, value string)

AddLabel adds a label/value pair for this metric.

func (*Metadata) Descriptor

func (*Metadata) Descriptor() ([]byte, []int)

func (*Metadata) Marshal

func (m *Metadata) Marshal() (dAtA []byte, err error)

func (*Metadata) MarshalTo

func (m *Metadata) MarshalTo(dAtA []byte) (int, error)

func (*Metadata) ProtoMessage

func (*Metadata) ProtoMessage()

func (*Metadata) Reset

func (m *Metadata) Reset()

func (*Metadata) Size

func (m *Metadata) Size() (n int)

func (*Metadata) String

func (m *Metadata) String() string

func (*Metadata) Unmarshal

func (m *Metadata) Unmarshal(dAtA []byte) error

type Metric

type Metric interface {
	// GetMetadata returns the metric's metadata.
	GetMetadata() Metadata
	// GetType returns the type enum for this metric.
	GetType() MetricType
	// Inspect calls the given closure with each contained item.
	Inspect(func(Metric))
	// ExportMetric returns a filled-in metric data of the right type for the given metric.
	ExportMetric() *MetricData
}

Metric provides a method for metric objects.

type MetricData

type MetricData struct {
	Counter     *CounterData     `protobuf:"bytes,1,opt,name=counter" json:"counter,omitempty"`
	CounterRate *CounterRateData `protobuf:"bytes,2,opt,name=counter_rate,json=counterRate" json:"counter_rate,omitempty"`
	Gauge       *GaugeData       `protobuf:"bytes,3,opt,name=gauge" json:"gauge,omitempty"`
	Histogram   *HistogramData   `protobuf:"bytes,4,opt,name=histogram" json:"histogram,omitempty"`
	Labels      []LabelPair      `protobuf:"bytes,5,rep,name=labels" json:"labels"`
	Unit        Unit             `protobuf:"varint,6,opt,name=unit,proto3,enum=Unit" json:"unit,omitempty"`
	TimestampNs int64            `protobuf:"varint,7,opt,name=TimestampNs,proto3" json:"TimestampNs,omitempty"`
}

MetricData holds exported data of metrics

func (*MetricData) Descriptor

func (*MetricData) Descriptor() ([]byte, []int)

func (*MetricData) Marshal

func (m *MetricData) Marshal() (dAtA []byte, err error)

func (*MetricData) MarshalTo

func (m *MetricData) MarshalTo(dAtA []byte) (int, error)

func (*MetricData) ProtoMessage

func (*MetricData) ProtoMessage()

func (*MetricData) Reset

func (m *MetricData) Reset()

func (*MetricData) Size

func (m *MetricData) Size() (n int)

func (*MetricData) String

func (m *MetricData) String() string

func (*MetricData) Unmarshal

func (m *MetricData) Unmarshal(dAtA []byte) error

type MetricFamily

type MetricFamily struct {
	Name    string       `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Help    string       `protobuf:"bytes,2,opt,name=help,proto3" json:"help,omitempty"`
	Type    MetricType   `protobuf:"varint,3,opt,name=type,proto3,enum=MetricType" json:"type,omitempty"`
	Metrics []MetricData `protobuf:"bytes,4,rep,name=metrics" json:"metrics"`
}

MetricFamily contains a list of metrics with the same name (a metric with multiple labels).

func (*MetricFamily) Descriptor

func (*MetricFamily) Descriptor() ([]byte, []int)

func (*MetricFamily) Marshal

func (m *MetricFamily) Marshal() (dAtA []byte, err error)

func (*MetricFamily) MarshalTo

func (m *MetricFamily) MarshalTo(dAtA []byte) (int, error)

func (*MetricFamily) ProtoMessage

func (*MetricFamily) ProtoMessage()

func (*MetricFamily) Reset

func (m *MetricFamily) Reset()

func (*MetricFamily) Size

func (m *MetricFamily) Size() (n int)

func (*MetricFamily) String

func (m *MetricFamily) String() string

func (*MetricFamily) Unmarshal

func (m *MetricFamily) Unmarshal(dAtA []byte) error

type MetricFamilySlice

type MetricFamilySlice []*MetricFamily

func (MetricFamilySlice) Len

func (s MetricFamilySlice) Len() int

func (MetricFamilySlice) Less

func (s MetricFamilySlice) Less(i int, j int) bool

func (MetricFamilySlice) Swap

func (s MetricFamilySlice) Swap(i int, j int)

type MetricStruct

type MetricStruct interface {
	MetricStruct()
}

MetricStruct can be implemented by the types of members of a metric container, so that the members get automatically registered.

type MetricType

type MetricType int32

MetricType describes the type of metric.

const (
	// UNSET expresses that the metric's type wasn't explicitly set.
	MetricType_UNTYPED     MetricType = 0
	MetricType_COUNTER     MetricType = 1
	MetricType_COUNTERRATE MetricType = 2
	MetricType_GAUGE       MetricType = 3
	MetricType_HISTOGRAM   MetricType = 4
)

func (MetricType) EnumDescriptor

func (MetricType) EnumDescriptor() ([]byte, []int)

func (MetricType) String

func (x MetricType) String() string

type Percentile

type Percentile struct {
	Name  string  `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Unit  float64 `protobuf:"fixed64,2,opt,name=unit,proto3" json:"unit,omitempty"`
	Value float64 `protobuf:"fixed64,3,opt,name=value,proto3" json:"value,omitempty"`
}

func (*Percentile) Descriptor

func (*Percentile) Descriptor() ([]byte, []int)

func (*Percentile) Marshal

func (m *Percentile) Marshal() (dAtA []byte, err error)

func (*Percentile) MarshalTo

func (m *Percentile) MarshalTo(dAtA []byte) (int, error)

func (*Percentile) ProtoMessage

func (*Percentile) ProtoMessage()

func (*Percentile) Reset

func (m *Percentile) Reset()

func (*Percentile) Size

func (m *Percentile) Size() (n int)

func (*Percentile) String

func (m *Percentile) String() string

func (*Percentile) Unmarshal

func (m *Percentile) Unmarshal(dAtA []byte) error

type Registry

type Registry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Registry is a list of metrics. It provides a simple way of iterating over them. A registry can have label pairs that will be applied to all its metrics when exported.

func NewRegistry

func NewRegistry() *Registry

NewRegistry create a Registry.

func (*Registry) AddLabel

func (r *Registry) AddLabel(name, value string)

AddLabel adds a label/value pair for this registry.

func (*Registry) AddMetric

func (r *Registry) AddMetric(metric ...Metric)

AddMetric adds the passed-in metric to the registry.

func (*Registry) AddMetricStruct

func (r *Registry) AddMetricStruct(metricStruct interface{})

AddMetricStruct adds all Metric or MetricStruct fields to the registry.

func (*Registry) Each

func (r *Registry) Each(f func(name string, val Metric))

Each calls the given closure for all metrics.

func (*Registry) FindMetric

func (r *Registry) FindMetric(name string) (m Metric)

FindMetric looking for metric based on name.

func (*Registry) GetLabels

func (r *Registry) GetLabels() (labels []LabelPair)

GetLabels return the label/value pairs of registry.

func (*Registry) MarshalJSON

func (r *Registry) MarshalJSON() ([]byte, error)

MarshalJSON marshals to JSON.

type Unit

type Unit int32

Unit describes how the metric's units should be displayed.

const (
	// UNSET expresses that the metric's DisplayUnit wasn't explicitly set.
	Unit_UNSET Unit = 0
	// BYTES expresses that the metric's measurement is in bytes.
	Unit_BYTES Unit = 1
	// CONST expresses that the metric's measurement is a constant value.
	Unit_CONST Unit = 2
	// COUNT expresses that the metric's measurement is a count.
	Unit_COUNT Unit = 3
	// NANOSECONDS expresses that the metric's measurement is in nanoseconds.
	Unit_NANOSECONDS Unit = 4
	// PERCENT expresses that the metric's measurement is a percentage value.
	Unit_PERCENT Unit = 5
	// SECONDS expresses that the metric's measurement is in seconds.
	Unit_SECONDS Unit = 6
)

func (Unit) EnumDescriptor

func (Unit) EnumDescriptor() ([]byte, []int)

func (Unit) String

func (x Unit) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL