telemetry

package
v0.0.0-...-7983b3b Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{

	NoDoubleUnderscoreSep: false,
}

DefaultOptions for telemetry metrics which don't need to specify any option.

Functions

func Handler

func Handler() http.Handler

Handler serves the HTTP route containing the prometheus metrics.

func Reset

func Reset()

Reset resets the global telemetry registry, stopping the collection of every previously registered metrics. Mainly used for unit tests and integration tests.

Types

type Counter

type Counter interface {
	// Initialize creates the counter with the given tags and initializes it to 0.
	// This method is intended to be used when the counter value is important to
	// send even before any incrementing/addition is done on it.
	Initialize(tagsValue ...string)
	// Inc increments the counter with the given tags value.
	Inc(tagsValue ...string)
	// Add adds the given value to the counter with the given tags value.
	Add(value float64, tagsValue ...string)
	// Delete deletes the value for the counter with the given tags value.
	Delete(tagsValue ...string)
	// IncWithTags increments the counter with the given tags.
	// Even if less convenient, this signature could be used in hot path
	// instead of Inc(...string) to avoid escaping the parameters on the heap.
	IncWithTags(tags map[string]string)
	// AddWithTags adds the given value to the counter with the given tags.
	// Even if less convenient, this signature could be used in hot path
	// instead of Add(float64, ...string) to avoid escaping the parameters on the heap.
	AddWithTags(value float64, tags map[string]string)
	// DeleteWithTags deletes the value for the counter with the given tags.
	// Even if less convenient, this signature could be used in hot path
	// instead of Delete(...string) to avoid escaping the parameters on the heap.
	DeleteWithTags(tags map[string]string)
	// WithValues returns SimpleCounter for this metric with the given tag values.
	WithValues(tagsValue ...string) SimpleCounter
	// WithTags returns SimpleCounter for this metric with the given tqg values.
	WithTags(tags map[string]string) SimpleCounter
}

Counter tracks how many times something is happening.

func NewCounter

func NewCounter(subsystem, name string, tags []string, help string) Counter

NewCounter creates a Counter with default options for telemetry purpose. Current implementation used: Prometheus Counter

func NewCounterWithOpts

func NewCounterWithOpts(subsystem, name string, tags []string, help string, opts Options) Counter

NewCounterWithOpts creates a Counter with the given options for telemetry purpose. See NewCounter()

type Gauge

type Gauge interface {
	// Set stores the value for the given tags.
	Set(value float64, tagsValue ...string)
	// Inc increments the Gauge value.
	Inc(tagsValue ...string)
	// Dec decrements the Gauge value.
	Dec(tagsValue ...string)
	// Add adds the value to the Gauge value.
	Add(value float64, tagsValue ...string)
	// Sub subtracts the value to the Gauge value.
	Sub(value float64, tagsValue ...string)
	// Delete deletes the value for the Gauge with the given tags.
	Delete(tagsValue ...string)
}

Gauge tracks the value of one health metric of the Agent.

func NewGauge

func NewGauge(subsystem, name string, tags []string, help string) Gauge

NewGauge creates a Gauge with default options for telemetry purpose. Current implementation used: Prometheus Gauge

func NewGaugeWithOpts

func NewGaugeWithOpts(subsystem, name string, tags []string, help string, opts Options) Gauge

NewGaugeWithOpts creates a Gauge with the given options for telemetry purpose. See NewGauge()

type Histogram

type Histogram interface {
	// Observe the value to the Histogram value.
	Observe(value float64, tagsValue ...string)
	// Delete deletes the value for the Histogram with the given tags.
	Delete(tagsValue ...string)
}

Histogram tracks the value of one health metric of the Agent.

func NewHistogram

func NewHistogram(subsystem, name string, tags []string, help string, buckets []float64) Histogram

NewHistogram creates a Histogram with default options for telemetry purpose. Current implementation used: Prometheus Histogram

func NewHistogramNoOp

func NewHistogramNoOp() Histogram

NewHistogramNoOp creates a dummy Histogram

func NewHistogramWithOpts

func NewHistogramWithOpts(subsystem, name string, tags []string, help string, buckets []float64, opts Options) Histogram

NewHistogramWithOpts creates a Histogram with the given options for telemetry purpose. See NewHistogram()

type Metrics

type Metrics struct {
	Values []RawMetrics
}

Metrics is a container structure for a list of raw metric values. This allows us to set Metrics of a batch payload as a pointer and append more metrics to the structure

type Options

type Options struct {
	// NoDoubleUnderscoreSep is set to true when you don't want to
	// separate the subsystem and the name with a double underscore separator.
	NoDoubleUnderscoreSep bool
}

Options for telemetry metrics. Creating an Options struct without specifying any of its fields should be the equivalent of using the DefaultOptions var.

func (*Options) NameWithSeparator

func (opts *Options) NameWithSeparator(subsystem, name string) string

NameWithSeparator returns name prefixed according to NoDoubleUnderscoreOption.

type RawMetrics

type RawMetrics struct {
	Name      string   `json:"name,omitempty"`
	Timestamp int64    `json:"timestamp,omitempty"`
	HostName  string   `json:"host_name,omitempty"`
	Value     float64  `json:"value,omitempty"`
	Tags      []string `json:"tags,omitempty"`
}

RawMetrics single payload structure

func (RawMetrics) ConvertToIntakeMetric

func (r RawMetrics) ConvertToIntakeMetric() []interface{}

ConvertToIntakeMetric Converts RawMetricsCheckData struct to an older v1 metrics structure

func (RawMetrics) IntakeMetricJSON

func (r RawMetrics) IntakeMetricJSON() (jsonObject []interface{})

IntakeMetricJSON Converts RawMetricsCheckData struct to an older v1 metrics structure, parses it to JSON and returns it as a interface. This is only used in batcher test assertions.

func (RawMetrics) JSONString

func (r RawMetrics) JSONString() string

JSONString returns a JSON string of the Component

type RawMetricsMetaData

type RawMetricsMetaData struct {
	Hostname string   `json:"hostname,omitempty"`
	Tags     []string `json:"tags,omitempty"`
	Type     string   `json:"type,omitempty"`
}

RawMetricsMetaData payload containing meta data for the metric

type SimpleCounter

type SimpleCounter interface {
	// Inc increments the counter.
	Inc()
	// Add increments the counter by given amount.
	Add(float64)
}

SimpleCounter tracks how many times something is happening.

func NewSimpleCounter

func NewSimpleCounter(subsystem, name, help string) SimpleCounter

NewSimpleCounter creates a new SimpleCounter with default options.

func NewSimpleCounterWithOpts

func NewSimpleCounterWithOpts(subsystem, name, help string, opts Options) SimpleCounter

NewSimpleCounterWithOpts creates a new SimpleCounter.

type Summary

type Summary interface {
	// Observe  the value to the Summary value.
	Observe(value float64, tagsValue ...string)
	// Delete deletes the value for the Summary with the given tags.
	Delete(tagsValue ...string)
}

Summary tracks the value of one health metric of the Agent.

func NewSummary

func NewSummary(subsystem, name string, tags []string, help string) Summary

NewSummary creates a Summary with default options for telemetry purpose. Current implementation used: Prometheus Summary

func NewSummaryNoOp

func NewSummaryNoOp() Summary

NewSummaryNoOp creates a dummy Summary

func NewSummaryWithOpts

func NewSummaryWithOpts(subsystem, name string, tags []string, help string, opts Options) Summary

NewSummaryWithOpts creates a Summary with the given options for telemetry purpose. See NewSummary()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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