telemetry

package
v0.0.0-...-102d8e4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package telemetry provides a way to collect metrics from eBPF programs.

Index

Constants

View Source
const (

	// OptStatsd designates a metric that should be emitted using statsd
	OptStatsd = "_statsd"

	// OptPrometheus designates a metric that should be emitted using prometheus
	OptPrometheus = "_prometheus"

	// OptPayloadTelemetry designates a metric that should be emitted as agent payload telemetry
	OptPayloadTelemetry = "_payload_telemetry"
)

Variables

This section is empty.

Functions

func Clear

func Clear()

Clear metrics WARNING: Only intended for tests

func Handler

func Handler(w http.ResponseWriter, _ *http.Request)

Handler is meant to be used in conjunction with a HTTP server for exposing the state of all metrics currently tracked by this library

func ReportPayloadTelemetry

func ReportPayloadTelemetry(clientID string) map[string]int64

ReportPayloadTelemetry returns a map with all metrics tagged with `OptPayloadTelemetry` The return format is consistent with what we use in the protobuf messages sent to the backend

func ReportPrometheus

func ReportPrometheus()

ReportPrometheus reports metrics to the Prometheus client.

func ReportStatsd

func ReportStatsd()

ReportStatsd flushes all metrics tagged with `ReportStatsd`

func SetStatsdClient

func SetStatsdClient(c statsd.ClientInterface)

SetStatsdClient used to report data during invocations of `ReportStatsd` TODO: should `ReportStatsd` receive a client instance instead?

Types

type Counter

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

Counter is a cumulative metric that grows monotonically

func NewCounter

func NewCounter(name string, tagsAndOptions ...string) *Counter

NewCounter returns a new metric of type `Counter`

func (*Counter) Add

func (c *Counter) Add(v int64)

Add value atomically

func (Counter) Get

func (m Counter) Get() int64

Get value atomically

func (Counter) Name

func (m Counter) Name() string

Name of the `Metric` (including tags)

type Gauge

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

Gauge is a metric that represents a numerical value that can arbitrarily go up and down

func NewGauge

func NewGauge(name string, tagsAndOptions ...string) *Gauge

NewGauge returns a new metric of type `Gauge`

func (*Gauge) Add

func (g *Gauge) Add(v int64)

Add value atomically

func (Gauge) Get

func (m Gauge) Get() int64

Get value atomically

func (Gauge) Name

func (m Gauge) Name() string

Name of the `Metric` (including tags)

func (*Gauge) Set

func (g *Gauge) Set(v int64)

Set value atomically

type MarshableMetric

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

MarshableMetric sole purpose is to provide a marshable representation of a metric

func (MarshableMetric) MarshalJSON

func (mm MarshableMetric) MarshalJSON() ([]byte, error)

MarshalJSON returns a json representation of the current `metric`

type MetricGroup

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

MetricGroup provides a convenient constructor for a group with metrics sharing the same namespace and group of tags. Note the usage of this API is entirely optional; I'm only adding this here to keep compatibility with some common patterns I've seen in the codebase.

func NewMetricGroup

func NewMetricGroup(namespace string, commonTags ...string) *MetricGroup

NewMetricGroup returns a new `MetricGroup`

func (*MetricGroup) NewCounter

func (mg *MetricGroup) NewCounter(name string, tags ...string) *Counter

NewCounter returns a new `Counter` using the provided namespace and common tags and associates it with the current metric group

func (*MetricGroup) NewGauge

func (mg *MetricGroup) NewGauge(name string, tags ...string) *Gauge

NewGauge returns a new `Gauge` using the provided namespace and common tags and associates it with the current metric group

func (*MetricGroup) Summary

func (mg *MetricGroup) Summary() string

Summary builds and returns a summary string all metrics beloging to the current `MetricGroup`. The string looks like: m1=100(50.00/s) m2=0(0.00/s) Where the values are calculated based on the deltas between calls of this method.

type TLSAwareCounter

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

TLSAwareCounter is a TLS aware counter, it has a plain counter and a counter for TLS. It enables the use of a single metric that increments based on the encryption, avoiding the need for separate metrics for eash use-case.

func NewTLSAwareCounter

func NewTLSAwareCounter(metricGroup *MetricGroup, metricName string, tags ...string) *TLSAwareCounter

NewTLSAwareCounter creates and returns a new instance of TLSCounter

func (*TLSAwareCounter) Add

func (c *TLSAwareCounter) Add(delta int64, isTLS bool)

Add adds the given delta to the counter based on the encryption.

func (*TLSAwareCounter) Get

func (c *TLSAwareCounter) Get(isTLS bool) int64

Get returns the counter value based on the encryption.

Jump to

Keyboard shortcuts

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