metrics

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var M = newMetrics()

Functions

func NewPrometheusHandler added in v0.4.0

func NewPrometheusHandler(registry *Registry) http.Handler

Types

type Channel

type Channel struct {
	*srv.GChannel
	// contains filtered or unexported fields
}

func NewMetricsChannel

func NewMetricsChannel(src transport.Channel, traffic *TunnelTraffic) *Channel

func (*Channel) Next added in v0.4.0

func (c *Channel) Next(pos int) ([]byte, error)

func (*Channel) Peek added in v0.4.0

func (c *Channel) Peek(n int) (buf []byte, err error)

func (*Channel) Read

func (c *Channel) Read(p []byte) (n int, err error)

func (*Channel) Write

func (c *Channel) Write(p []byte) (n int, err error)

type Collector added in v0.4.0

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

func NewCollector added in v0.4.0

func NewCollector(registry *Registry) *Collector

func (*Collector) GetTraffic added in v0.4.0

func (c *Collector) GetTraffic(id string) (*TunnelTraffic, bool)

func (*Collector) Register added in v0.4.0

func (c *Collector) Register(server TunnelMetrics) *TunnelTraffic

func (*Collector) Snapshot added in v0.4.0

func (c *Collector) Snapshot() []TunnelTrafficSnapshot

func (*Collector) Unregister added in v0.4.0

func (c *Collector) Unregister(id string)

type ConsoleReporter added in v0.4.0

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

func NewConsoleReporter added in v0.4.0

func NewConsoleReporter(registry *Registry, interval time.Duration) *ConsoleReporter

func (*ConsoleReporter) Start added in v0.4.0

func (r *ConsoleReporter) Start()

func (*ConsoleReporter) Stop added in v0.4.0

func (r *ConsoleReporter) Stop()

type Metrics

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

func (*Metrics) GetServers

func (m *Metrics) GetServers() []TunnelMetrics

func (*Metrics) GetTraffics

func (m *Metrics) GetTraffics(id string) (*TunnelTraffic, bool)

func (*Metrics) PrometheusHandler added in v0.4.0

func (m *Metrics) PrometheusHandler() http.Handler

func (*Metrics) PutServer

func (m *Metrics) PutServer(server TunnelMetrics) *TunnelTraffic

func (*Metrics) PutTraffics

func (m *Metrics) PutTraffics(traffic *TunnelTraffic)

func (*Metrics) RemoveServer

func (m *Metrics) RemoveServer(server TunnelMetrics)

func (*Metrics) Snapshot added in v0.4.0

func (m *Metrics) Snapshot() []TunnelTrafficSnapshot

type PrometheusExporter added in v0.4.0

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

func NewPrometheusExporter added in v0.4.0

func NewPrometheusExporter(registry *Registry) *PrometheusExporter

func (*PrometheusExporter) Collect added in v0.4.0

func (e *PrometheusExporter) Collect(ch chan<- prometheus.Metric)

func (*PrometheusExporter) Describe added in v0.4.0

func (e *PrometheusExporter) Describe(ch chan<- *prometheus.Desc)

type Registry added in v0.4.0

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

func NewRegistry added in v0.4.0

func NewRegistry(window, interval, ttl time.Duration) *Registry

func (*Registry) GetTraffic added in v0.4.0

func (r *Registry) GetTraffic(id string) (*TunnelTraffic, bool)

func (*Registry) Register added in v0.4.0

func (r *Registry) Register(server TunnelMetrics) *TunnelTraffic

func (*Registry) Snapshot added in v0.4.0

func (r *Registry) Snapshot() []TunnelTrafficSnapshot

func (*Registry) SweepExpired added in v0.4.0

func (r *Registry) SweepExpired() []string

func (*Registry) Touch added in v0.4.0

func (r *Registry) Touch(id string)

func (*Registry) Unregister added in v0.4.0

func (r *Registry) Unregister(id string)

type TunnelMetrics

type TunnelMetrics interface {
	Id() string
	Name() string
	Port() int
	Type() string
	Connections() int
	Clients() int
	Runtime() time.Time
	ClientsInfo() []transport.Channel
}

type TunnelTraffic

type TunnelTraffic struct {
	Id string
	// contains filtered or unexported fields
}

func NewTunnelTraffic

func NewTunnelTraffic(id string, port int, name string, window time.Duration, interval time.Duration) *TunnelTraffic

func (*TunnelTraffic) AddInBytes

func (ts *TunnelTraffic) AddInBytes(bytes int)

func (*TunnelTraffic) AddOutBytes

func (ts *TunnelTraffic) AddOutBytes(bytes int)

func (*TunnelTraffic) InRateBps added in v0.4.0

func (ts *TunnelTraffic) InRateBps() float64

func (*TunnelTraffic) LatencyMs added in v0.4.0

func (ts *TunnelTraffic) LatencyMs() float64

func (*TunnelTraffic) Name added in v0.4.0

func (ts *TunnelTraffic) Name() string

func (*TunnelTraffic) ObserveLatency added in v0.4.0

func (ts *TunnelTraffic) ObserveLatency(d time.Duration)

func (*TunnelTraffic) OutRateBps added in v0.4.0

func (ts *TunnelTraffic) OutRateBps() float64

func (*TunnelTraffic) Port added in v0.4.0

func (ts *TunnelTraffic) Port() int

func (*TunnelTraffic) Rate added in v0.4.0

func (ts *TunnelTraffic) Rate() (float64, float64)

func (*TunnelTraffic) Sum

func (ts *TunnelTraffic) Sum() (in uint64, out uint64)

type TunnelTrafficSnapshot added in v0.4.0

type TunnelTrafficSnapshot struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Type        string    `json:"type"`
	Port        int       `json:"port"`
	Connections int       `json:"connections"`
	Clients     int       `json:"clients"`
	Runtime     time.Time `json:"runtime"`
	LastSeen    time.Time `json:"last_seen"`
	AgeSeconds  float64   `json:"age_seconds"`
	InBytes     uint64    `json:"in_bytes"`
	OutBytes    uint64    `json:"out_bytes"`
	InRateBps   float64   `json:"in_rate_bps"`
	OutRateBps  float64   `json:"out_rate_bps"`
	LatencyMs   float64   `json:"latency_ms"`
}

Jump to

Keyboard shortcuts

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