telemetry

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callbacks

type Callbacks struct {
	// GetAllocationCount should map to the total allocation counter of the server.
	GetAllocationCount func() int64
	// GetBuildInfo returns the version of the binary, exported as the build info metric.
	GetBuildInfo func() buildinfo.BuildInfo
}

Callbacks lets the caller to define various callbacks for reporting active metrics from an object that cannot be reached from this subpackage. This interface allows to easily add new metric reporters.

type ConnType

type ConnType int

ConnType specifies whether a conn stat was collected at a listener or a cluster.

const (
	ListenerType ConnType = iota + 1
	ClusterType
)

func (ConnType) String

func (c ConnType) String() string

String returns a string representation for a ConnType.

type Counters

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

Counters counts the traffic of one listener or cluster. It builds the metric attributes of both directions once, so the per-packet path neither allocates nor hashes the name.

func (*Counters) Add

func (c *Counters) Add(d Direction, n int)

Add counts a packet of n bytes in direction d.

type Direction

type Direction int

Direction specifies whether a conn stat applies in the sender or a receiving direction from the standpoint of STUNner.

const (
	Incoming Direction = iota + 1
	Outgoing
)

func (Direction) String

func (d Direction) String() string

String returns a string representation for a Direction.

type Telemetry

type Telemetry struct {
	sdkmetric.Reader

	// Metrics instruments
	ListenerPacketsCounter metric.Int64Counter
	ListenerBytesCounter   metric.Int64Counter
	ListenerConnsCounter   metric.Int64Counter
	ListenerConnsGauge     metric.Int64UpDownCounter
	ClusterPacketsCounter  metric.Int64Counter
	ClusterBytesCounter    metric.Int64Counter
	AllocationsGauge       metric.Int64ObservableGauge
	BuildInfoGauge         metric.Int64ObservableGauge
	// contains filtered or unexported fields
}

func New

func New(callbacks Callbacks, dryRun bool, log logging.LeveledLogger) (*Telemetry, error)

func (*Telemetry) AddConnection

func (t *Telemetry) AddConnection(n string, c ConnType)

func (*Telemetry) Close

func (t *Telemetry) Close() error

Close cleanly shuts down the meter provider and blocks until the shutdown cycle is finished or a timeout expires.

func (*Telemetry) Counters

func (t *Telemetry) Counters(n string, c ConnType) *Counters

Counters returns the traffic counters of a listener (ListenerType) or a cluster (ClusterType).

func (*Telemetry) Ctx

func (t *Telemetry) Ctx() context.Context

func (*Telemetry) IncrementBytes

func (t *Telemetry) IncrementBytes(n string, c ConnType, d Direction, count uint64)

func (*Telemetry) IncrementPackets

func (t *Telemetry) IncrementPackets(n string, c ConnType, d Direction, count uint64)

func (*Telemetry) Stats

func (t *Telemetry) Stats(n string, c ConnType) stnrv2.DirStat

Stats returns the traffic a listener (ListenerType) or a cluster (ClusterType) carried, in user space and, as the offload reporter adds it, in the kernel.

func (*Telemetry) SubConnection

func (t *Telemetry) SubConnection(n string, c ConnType)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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