latency

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MetricLatencyRttMin = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "doublezero_latency_rtt_min_nanoseconds",
			Help: "Minimum round-trip time latency to DoubleZero devices in nanoseconds.",
		},
		latencyLabels,
	)
	MetricLatencyRttAvg = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "doublezero_latency_rtt_avg_nanoseconds",
			Help: "Average round-trip time latency to DoubleZero devices in nanoseconds.",
		},
		latencyLabels,
	)
	MetricLatencyRttMax = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "doublezero_latency_rtt_max_nanoseconds",
			Help: "Maximum round-trip time latency to DoubleZero devices in nanoseconds.",
		},
		latencyLabels,
	)

	MetricLatencyLoss = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "doublezero_latency_loss_percentage",
			Help: "Packet loss percentage to DoubleZero devices.",
		},
		latencyLabels,
	)

	MetricLatencyReachable = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "doublezero_latency_reachable",
			Help: "Indicates if a device is reachable (1 for reachable, 0 for unreachable).",
		},
		latencyLabels,
	)
)

Functions

This section is empty.

Types

type ContractData

type ContractData struct {
	Locations []serviceability.Location
	Devices   []serviceability.Device
	Exchanges []serviceability.Exchange
	Links     []serviceability.Link
	Users     []serviceability.User
}

func FetchContractData

func FetchContractData(ctx context.Context, programId string, rpcEndpoint string) (*ContractData, error)

type DeviceCache

type DeviceCache struct {
	Devices []serviceability.Device
	Lock    sync.Mutex
}

type LatencyManager

type LatencyManager struct {
	SmartContractFunc SmartContractorFunc

	DeviceCache  *DeviceCache
	ResultsCache *LatencyResults
	// contains filtered or unexported fields
}

func NewLatencyManager

func NewLatencyManager(options ...Option) *LatencyManager

func (*LatencyManager) GetDeviceCache

func (l *LatencyManager) GetDeviceCache() []serviceability.Device

func (*LatencyManager) GetResultsCache

func (l *LatencyManager) GetResultsCache() []LatencyResult

func (*LatencyManager) ServeLatency

func (l *LatencyManager) ServeLatency(w http.ResponseWriter, r *http.Request)

func (*LatencyManager) Start

func (l *LatencyManager) Start(ctx context.Context) error

type LatencyResult

type LatencyResult struct {
	Min       int64                 `json:"min_latency_ns"`
	Max       int64                 `json:"max_latency_ns"`
	Avg       int64                 `json:"avg_latency_ns"`
	Loss      float64               `json:"loss_percentage"`
	Device    serviceability.Device `json:"-"`
	Reachable bool                  `json:"reachable"`
}

func (*LatencyResult) MarshalJSON

func (l *LatencyResult) MarshalJSON() ([]byte, error)

type LatencyResults

type LatencyResults struct {
	Results []LatencyResult
	Lock    sync.RWMutex `json:"-"`
}

func (*LatencyResults) MarshalJSON

func (l *LatencyResults) MarshalJSON() ([]byte, error)

type Option added in v0.7.2

type Option func(*LatencyManager)

func WithCacheUpdateInterval added in v0.7.2

func WithCacheUpdateInterval(interval time.Duration) Option

func WithMetricsEnabled added in v0.7.2

func WithMetricsEnabled(enabled bool) Option

func WithProbeInterval added in v0.7.2

func WithProbeInterval(interval time.Duration) Option

func WithProberFunc added in v0.7.2

func WithProberFunc(f ProberFunc) Option

func WithProgramID added in v0.7.2

func WithProgramID(id string) Option

func WithRpcEndpoint added in v0.7.2

func WithRpcEndpoint(endpoint string) Option

func WithSmartContractFunc added in v0.7.2

func WithSmartContractFunc(f SmartContractorFunc) Option

type SmartContractorFunc

type SmartContractorFunc func(context.Context, string, string) (*ContractData, error)

Jump to

Keyboard shortcuts

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