metrics

package
v0.0.12-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Copyright (c) Microsoft Corporation. Licensed under the MIT License. Package metrics provides a metrics collector that stores metrics in Prometheus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPromMetrics

func NewPromMetrics(reg prometheus.Registerer, name, prefix string) *promMetrics

NewPromMetrics creates a new instance of promMetrics.

func WithContext

func WithContext(ctx context.Context, name, prefix string) (context.Context, error)

WithContext returns a new context with an metrics recorder.

Types

type Metrics

type Metrics interface {
	// RecordRequest records the time it takes to process a request.
	RecordRequest(method, handler string, duration float64)

	// RecordPeerDiscovery records the time it takes to discover a peer.
	RecordPeerDiscovery(ip string, duration float64)

	// RecordPeerResponse records the time it takes for a peer to respond for a key.
	RecordPeerResponse(ip, key, op string, duration float64, count int64)

	// RecordUpstreamResponse records the time it takes for an upstream to respond for a key.
	RecordUpstreamResponse(hostname, key, op string, duration float64, count int64)
}

Metrics defines an interface to collect p2p metrics.

func FromContext

func FromContext(ctx context.Context) Metrics

FromContext returns the metrics recorder from the context.

Jump to

Keyboard shortcuts

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