Documentation ¶
Overview ¶
Package telemetry provides a way to collect metrics from eBPF programs.
Index ¶
Constants ¶
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 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 ¶
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 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 ¶
NewCounter returns a new metric of type `Counter`
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
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.
func (*TLSAwareCounter) Set ¶
func (c *TLSAwareCounter) Set(v int64, isTLS bool)
Set Sets the given value to the counter based on the encryption.