io_metric_client

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: BSD-3-Clause Imports: 2 Imported by: 3

Documentation

Overview

Package io_metric_client provides metric types for Prometheus-compatible metrics. This is the native Go implementation without protobuf dependency.

Index

Constants

This section is empty.

Variables

View Source
var MetricType_name = map[int32]string{
	0: "COUNTER",
	1: "GAUGE",
	2: "SUMMARY",
	3: "UNTYPED",
	4: "HISTOGRAM",
	5: "GAUGE_HISTOGRAM",
}

MetricType_name maps enum values to names.

View Source
var MetricType_value = map[string]int32{
	"COUNTER":         0,
	"GAUGE":           1,
	"SUMMARY":         2,
	"UNTYPED":         3,
	"HISTOGRAM":       4,
	"GAUGE_HISTOGRAM": 5,
}

MetricType_value maps names to enum values.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	CumulativeCount      *uint64   `json:"cumulative_count,omitempty"`
	CumulativeCountFloat *float64  `json:"cumulative_count_float,omitempty"`
	UpperBound           *float64  `json:"upper_bound,omitempty"`
	Exemplar             *Exemplar `json:"exemplar,omitempty"`
}

Bucket represents a histogram bucket.

func (*Bucket) GetCumulativeCount

func (x *Bucket) GetCumulativeCount() uint64

GetCumulativeCount returns the CumulativeCount field value or 0 if nil.

func (*Bucket) GetCumulativeCountFloat

func (x *Bucket) GetCumulativeCountFloat() float64

GetCumulativeCountFloat returns the CumulativeCountFloat field value or 0 if nil.

func (*Bucket) GetExemplar

func (x *Bucket) GetExemplar() *Exemplar

GetExemplar returns the Exemplar field value or nil if not set.

func (*Bucket) GetUpperBound

func (x *Bucket) GetUpperBound() float64

GetUpperBound returns the UpperBound field value or 0 if nil.

func (*Bucket) Reset

func (x *Bucket) Reset()

Reset resets the Bucket to its zero value.

func (*Bucket) String

func (x *Bucket) String() string

String returns the JSON representation of the Bucket.

type BucketSpan

type BucketSpan struct {
	Offset *int32  `json:"offset,omitempty"`
	Length *uint32 `json:"length,omitempty"`
}

BucketSpan defines a number of consecutive buckets in a native histogram.

func (*BucketSpan) GetLength

func (x *BucketSpan) GetLength() uint32

GetLength returns the Length field value or 0 if nil.

func (*BucketSpan) GetOffset

func (x *BucketSpan) GetOffset() int32

GetOffset returns the Offset field value or 0 if nil.

func (*BucketSpan) Reset

func (x *BucketSpan) Reset()

Reset resets the BucketSpan to its zero value.

func (*BucketSpan) String

func (x *BucketSpan) String() string

String returns the JSON representation of the BucketSpan.

type Counter

type Counter struct {
	Value            *float64   `json:"value,omitempty"`
	Exemplar         *Exemplar  `json:"exemplar,omitempty"`
	CreatedTimestamp *Timestamp `json:"created_timestamp,omitempty"`
}

Counter represents a counter metric value.

func (*Counter) GetCreatedTimestamp

func (x *Counter) GetCreatedTimestamp() *Timestamp

GetCreatedTimestamp returns the CreatedTimestamp field value or nil if not set.

func (*Counter) GetExemplar

func (x *Counter) GetExemplar() *Exemplar

GetExemplar returns the Exemplar field value or nil if not set.

func (*Counter) GetValue

func (x *Counter) GetValue() float64

GetValue returns the Value field value or 0 if nil.

func (*Counter) Reset

func (x *Counter) Reset()

Reset resets the Counter to its zero value.

func (*Counter) String

func (x *Counter) String() string

String returns the JSON representation of the Counter.

type Exemplar

type Exemplar struct {
	Label     []*LabelPair `json:"label,omitempty"`
	Value     *float64     `json:"value,omitempty"`
	Timestamp *Timestamp   `json:"timestamp,omitempty"`
}

Exemplar represents an exemplar for a metric.

func (*Exemplar) GetLabel

func (x *Exemplar) GetLabel() []*LabelPair

GetLabel returns the Label field slice or nil if not set.

func (*Exemplar) GetTimestamp

func (x *Exemplar) GetTimestamp() *Timestamp

GetTimestamp returns the Timestamp field value or nil if not set.

func (*Exemplar) GetValue

func (x *Exemplar) GetValue() float64

GetValue returns the Value field value or 0 if nil.

func (*Exemplar) Reset

func (x *Exemplar) Reset()

Reset resets the Exemplar to its zero value.

func (*Exemplar) String

func (x *Exemplar) String() string

String returns the JSON representation of the Exemplar.

type Gauge

type Gauge struct {
	Value *float64 `json:"value,omitempty"`
}

Gauge represents a gauge metric value.

func (*Gauge) GetValue

func (x *Gauge) GetValue() float64

GetValue returns the Value field value or 0 if nil.

func (*Gauge) Reset

func (x *Gauge) Reset()

Reset resets the Gauge to its zero value.

func (*Gauge) String

func (x *Gauge) String() string

String returns the JSON representation of the Gauge.

type Histogram

type Histogram struct {
	SampleCount      *uint64       `json:"sample_count,omitempty"`
	SampleCountFloat *float64      `json:"sample_count_float,omitempty"`
	SampleSum        *float64      `json:"sample_sum,omitempty"`
	Bucket           []*Bucket     `json:"bucket,omitempty"`
	CreatedTimestamp *Timestamp    `json:"created_timestamp,omitempty"`
	Schema           *int32        `json:"schema,omitempty"`
	ZeroThreshold    *float64      `json:"zero_threshold,omitempty"`
	ZeroCount        *uint64       `json:"zero_count,omitempty"`
	ZeroCountFloat   *float64      `json:"zero_count_float,omitempty"`
	NegativeSpan     []*BucketSpan `json:"negative_span,omitempty"`
	NegativeDelta    []int64       `json:"negative_delta,omitempty"`
	NegativeCount    []float64     `json:"negative_count,omitempty"`
	PositiveSpan     []*BucketSpan `json:"positive_span,omitempty"`
	PositiveDelta    []int64       `json:"positive_delta,omitempty"`
	PositiveCount    []float64     `json:"positive_count,omitempty"`
	Exemplars        []*Exemplar   `json:"exemplars,omitempty"`
}

Histogram represents a histogram metric value.

func (*Histogram) GetBucket

func (x *Histogram) GetBucket() []*Bucket

GetBucket returns the Bucket field slice or nil if not set.

func (*Histogram) GetCreatedTimestamp

func (x *Histogram) GetCreatedTimestamp() *Timestamp

GetCreatedTimestamp returns the CreatedTimestamp field value or nil if not set.

func (*Histogram) GetExemplars

func (x *Histogram) GetExemplars() []*Exemplar

GetExemplars returns the Exemplars field slice or nil if not set.

func (*Histogram) GetNegativeCount

func (x *Histogram) GetNegativeCount() []float64

GetNegativeCount returns the NegativeCount field slice or nil if not set.

func (*Histogram) GetNegativeDelta

func (x *Histogram) GetNegativeDelta() []int64

GetNegativeDelta returns the NegativeDelta field slice or nil if not set.

func (*Histogram) GetNegativeSpan

func (x *Histogram) GetNegativeSpan() []*BucketSpan

GetNegativeSpan returns the NegativeSpan field slice or nil if not set.

func (*Histogram) GetPositiveCount

func (x *Histogram) GetPositiveCount() []float64

GetPositiveCount returns the PositiveCount field slice or nil if not set.

func (*Histogram) GetPositiveDelta

func (x *Histogram) GetPositiveDelta() []int64

GetPositiveDelta returns the PositiveDelta field slice or nil if not set.

func (*Histogram) GetPositiveSpan

func (x *Histogram) GetPositiveSpan() []*BucketSpan

GetPositiveSpan returns the PositiveSpan field slice or nil if not set.

func (*Histogram) GetSampleCount

func (x *Histogram) GetSampleCount() uint64

GetSampleCount returns the SampleCount field value or 0 if nil.

func (*Histogram) GetSampleCountFloat

func (x *Histogram) GetSampleCountFloat() float64

GetSampleCountFloat returns the SampleCountFloat field value or 0 if nil.

func (*Histogram) GetSampleSum

func (x *Histogram) GetSampleSum() float64

GetSampleSum returns the SampleSum field value or 0 if nil.

func (*Histogram) GetSchema

func (x *Histogram) GetSchema() int32

GetSchema returns the Schema field value or 0 if nil.

func (*Histogram) GetZeroCount

func (x *Histogram) GetZeroCount() uint64

GetZeroCount returns the ZeroCount field value or 0 if nil.

func (*Histogram) GetZeroCountFloat

func (x *Histogram) GetZeroCountFloat() float64

GetZeroCountFloat returns the ZeroCountFloat field value or 0 if nil.

func (*Histogram) GetZeroThreshold

func (x *Histogram) GetZeroThreshold() float64

GetZeroThreshold returns the ZeroThreshold field value or 0 if nil.

func (*Histogram) Reset

func (x *Histogram) Reset()

Reset resets the Histogram to its zero value.

func (*Histogram) String

func (x *Histogram) String() string

String returns the JSON representation of the Histogram.

type LabelPair

type LabelPair struct {
	Name  *string `json:"name,omitempty"`
	Value *string `json:"value,omitempty"`
}

LabelPair is a name-value pair for metric labels.

func (*LabelPair) GetName

func (x *LabelPair) GetName() string

GetName returns the Name field value or empty string if nil.

func (*LabelPair) GetValue

func (x *LabelPair) GetValue() string

GetValue returns the Value field value or empty string if nil.

func (*LabelPair) Reset

func (x *LabelPair) Reset()

Reset resets the LabelPair to its zero value.

func (*LabelPair) String

func (x *LabelPair) String() string

String returns the JSON representation of the LabelPair.

type Metric

type Metric struct {
	Label       []*LabelPair `json:"label,omitempty"`
	Gauge       *Gauge       `json:"gauge,omitempty"`
	Counter     *Counter     `json:"counter,omitempty"`
	Summary     *Summary     `json:"summary,omitempty"`
	Untyped     *Untyped     `json:"untyped,omitempty"`
	Histogram   *Histogram   `json:"histogram,omitempty"`
	TimestampMs *int64       `json:"timestamp_ms,omitempty"`
}

Metric represents a single metric with its labels and values.

func (*Metric) GetCounter

func (x *Metric) GetCounter() *Counter

GetCounter returns the Counter field value or nil if not set.

func (*Metric) GetGauge

func (x *Metric) GetGauge() *Gauge

GetGauge returns the Gauge field value or nil if not set.

func (*Metric) GetHistogram

func (x *Metric) GetHistogram() *Histogram

GetHistogram returns the Histogram field value or nil if not set.

func (*Metric) GetLabel

func (x *Metric) GetLabel() []*LabelPair

GetLabel returns the Label field slice or nil if not set.

func (*Metric) GetSummary

func (x *Metric) GetSummary() *Summary

GetSummary returns the Summary field value or nil if not set.

func (*Metric) GetTimestampMs

func (x *Metric) GetTimestampMs() int64

GetTimestampMs returns the TimestampMs field value or 0 if nil.

func (*Metric) GetUntyped

func (x *Metric) GetUntyped() *Untyped

GetUntyped returns the Untyped field value or nil if not set.

func (*Metric) Reset

func (x *Metric) Reset()

Reset resets the Metric to its zero value.

func (*Metric) String

func (x *Metric) String() string

String returns the JSON representation of the Metric.

type MetricFamily

type MetricFamily struct {
	Name   *string     `json:"name,omitempty"`
	Help   *string     `json:"help,omitempty"`
	Type   *MetricType `json:"type,omitempty"`
	Metric []*Metric   `json:"metric,omitempty"`
	Unit   *string     `json:"unit,omitempty"`
}

MetricFamily is a collection of metrics with the same name and type.

func (*MetricFamily) GetHelp

func (x *MetricFamily) GetHelp() string

GetHelp returns the Help field value or empty string if nil.

func (*MetricFamily) GetMetric

func (x *MetricFamily) GetMetric() []*Metric

GetMetric returns the Metric field slice or nil if not set.

func (*MetricFamily) GetName

func (x *MetricFamily) GetName() string

GetName returns the Name field value or empty string if nil.

func (*MetricFamily) GetType

func (x *MetricFamily) GetType() MetricType

GetType returns the Type field value or MetricType_COUNTER if nil.

func (*MetricFamily) GetUnit

func (x *MetricFamily) GetUnit() string

GetUnit returns the Unit field value or empty string if nil.

func (*MetricFamily) Reset

func (x *MetricFamily) Reset()

Reset resets the MetricFamily to its zero value.

func (*MetricFamily) String

func (x *MetricFamily) String() string

String returns the JSON representation of the MetricFamily.

type MetricType

type MetricType int32

MetricType defines the type of a metric.

const (
	// MetricType_COUNTER must use the Metric field "counter".
	MetricType_COUNTER MetricType = 0
	// MetricType_GAUGE must use the Metric field "gauge".
	MetricType_GAUGE MetricType = 1
	// MetricType_SUMMARY must use the Metric field "summary".
	MetricType_SUMMARY MetricType = 2
	// MetricType_UNTYPED must use the Metric field "untyped".
	MetricType_UNTYPED MetricType = 3
	// MetricType_HISTOGRAM must use the Metric field "histogram".
	MetricType_HISTOGRAM MetricType = 4
	// MetricType_GAUGE_HISTOGRAM must use the Metric field "histogram".
	MetricType_GAUGE_HISTOGRAM MetricType = 5
)

func (MetricType) Enum

func (x MetricType) Enum() *MetricType

Enum returns a pointer to the MetricType.

func (MetricType) String

func (x MetricType) String() string

String returns the string representation of the MetricType.

type Quantile

type Quantile struct {
	Quantile *float64 `json:"quantile,omitempty"`
	Value    *float64 `json:"value,omitempty"`
}

Quantile represents a quantile value in a summary.

func (*Quantile) GetQuantile

func (x *Quantile) GetQuantile() float64

GetQuantile returns the Quantile field value or 0 if nil.

func (*Quantile) GetValue

func (x *Quantile) GetValue() float64

GetValue returns the Value field value or 0 if nil.

func (*Quantile) Reset

func (x *Quantile) Reset()

Reset resets the Quantile to its zero value.

func (*Quantile) String

func (x *Quantile) String() string

String returns the JSON representation of the Quantile.

type Summary

type Summary struct {
	SampleCount      *uint64     `json:"sample_count,omitempty"`
	SampleSum        *float64    `json:"sample_sum,omitempty"`
	Quantile         []*Quantile `json:"quantile,omitempty"`
	CreatedTimestamp *Timestamp  `json:"created_timestamp,omitempty"`
}

Summary represents a summary metric value.

func (*Summary) GetCreatedTimestamp

func (x *Summary) GetCreatedTimestamp() *Timestamp

GetCreatedTimestamp returns the CreatedTimestamp field value or nil if not set.

func (*Summary) GetQuantile

func (x *Summary) GetQuantile() []*Quantile

GetQuantile returns the Quantile field slice or nil if not set.

func (*Summary) GetSampleCount

func (x *Summary) GetSampleCount() uint64

GetSampleCount returns the SampleCount field value or 0 if nil.

func (*Summary) GetSampleSum

func (x *Summary) GetSampleSum() float64

GetSampleSum returns the SampleSum field value or 0 if nil.

func (*Summary) Reset

func (x *Summary) Reset()

Reset resets the Summary to its zero value.

func (*Summary) String

func (x *Summary) String() string

String returns the JSON representation of the Summary.

type Timestamp added in v1.5.0

type Timestamp struct {
	Seconds int64 `json:"seconds,omitempty"`
	Nanos   int32 `json:"nanos,omitempty"`
}

Timestamp represents a point in time.

func NewTimestamp added in v1.5.0

func NewTimestamp(t time.Time) *Timestamp

NewTimestamp creates a Timestamp from a time.Time.

func (*Timestamp) AsTime added in v1.5.0

func (t *Timestamp) AsTime() time.Time

AsTime converts the Timestamp to a time.Time.

type Untyped

type Untyped struct {
	Value *float64 `json:"value,omitempty"`
}

Untyped represents an untyped metric value.

func (*Untyped) GetValue

func (x *Untyped) GetValue() float64

GetValue returns the Value field value or 0 if nil.

func (*Untyped) Reset

func (x *Untyped) Reset()

Reset resets the Untyped to its zero value.

func (*Untyped) String

func (x *Untyped) String() string

String returns the JSON representation of the Untyped.

Jump to

Keyboard shortcuts

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