metrics

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MeasureConn

func MeasureConn(conn onet.DuplexConn, bytesSent, bytesReceived *int64) onet.DuplexConn

Types

type NoOpMetrics

type NoOpMetrics struct{}

NoOpMetrics is a fake ShadowsocksMetrics that doesn't do anything. Useful in tests or if you don't want to track metrics.

func (*NoOpMetrics) AddClosedTCPConnection

func (m *NoOpMetrics) AddClosedTCPConnection(clientLocation, accessKey, status string, data ProxyMetrics, timeToCipher, duration time.Duration)

func (*NoOpMetrics) AddOpenTCPConnection

func (m *NoOpMetrics) AddOpenTCPConnection(clientLocation string)

func (*NoOpMetrics) AddTCPProbe

func (m *NoOpMetrics) AddTCPProbe(clientLocation, status, drainResult string, port int, data ProxyMetrics)

func (*NoOpMetrics) AddUDPNatEntry

func (m *NoOpMetrics) AddUDPNatEntry()

func (*NoOpMetrics) AddUDPPacketFromClient

func (m *NoOpMetrics) AddUDPPacketFromClient(clientLocation, accessKey, status string, clientProxyBytes, proxyTargetBytes int, timeToCipher time.Duration)

func (*NoOpMetrics) AddUDPPacketFromTarget

func (m *NoOpMetrics) AddUDPPacketFromTarget(clientLocation, accessKey, status string, targetProxyBytes, proxyClientBytes int)

func (*NoOpMetrics) GetLocation

func (m *NoOpMetrics) GetLocation(net.Addr) (string, error)

func (*NoOpMetrics) RemoveUDPNatEntry

func (m *NoOpMetrics) RemoveUDPNatEntry()

func (*NoOpMetrics) SetBuildInfo

func (m *NoOpMetrics) SetBuildInfo(version string)

func (*NoOpMetrics) SetNumAccessKeys

func (m *NoOpMetrics) SetNumAccessKeys(numKeys int, numPorts int)

type ProxyMetrics

type ProxyMetrics struct {
	ClientProxy int64
	ProxyTarget int64
	TargetProxy int64
	ProxyClient int64
}

type ShadowsocksMetrics

type ShadowsocksMetrics interface {
	SetBuildInfo(version string)

	GetLocation(net.Addr) (string, error)

	SetNumAccessKeys(numKeys int, numPorts int)

	// TCP metrics
	AddOpenTCPConnection(clientLocation string)
	AddClosedTCPConnection(clientLocation, accessKey, status string, data ProxyMetrics, timeToCipher, duration time.Duration)
	AddTCPProbe(clientLocation, status, drainResult string, port int, data ProxyMetrics)

	// UDP metrics
	AddUDPPacketFromClient(clientLocation, accessKey, status string, clientProxyBytes, proxyTargetBytes int, timeToCipher time.Duration)
	AddUDPPacketFromTarget(clientLocation, accessKey, status string, targetProxyBytes, proxyClientBytes int)
	AddUDPNatEntry()
	RemoveUDPNatEntry()
}

ShadowsocksMetrics registers metrics for the Shadowsocks service.

func NewPrometheusShadowsocksMetrics

func NewPrometheusShadowsocksMetrics(ipCountryDB *geoip2.Reader, registerer prometheus.Registerer) ShadowsocksMetrics

NewPrometheusShadowsocksMetrics constructs a metrics object that uses `ipCountryDB` to convert IP addresses to countries, and reports all metrics to Prometheus via `registerer`. `ipCountryDB` may be nil, but `registerer` must not be.

Jump to

Keyboard shortcuts

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