metrics

package
v0.0.0-...-81c6e22 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RequestPath is the path in the microVM hosting remote snapshotter metrics.
	RequestPath = "http://localhost/metrics"
	// MaxMetricsResponseSize is the limit in bytes for size of a metrics response from a remote snapshotter.
	MaxMetricsResponseSize = 32768 // 32 KB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPClient

type HTTPClient interface {
	Get(string) (*http.Response, error)
}

HTTPClient defines the interface for the client getting metrics.

type Monitor

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

Monitor is used for port and lifecycle management of metrics proxies.

func NewMonitor

func NewMonitor(startPort, endPort int) (*Monitor, error)

NewMonitor returns a new metrics proxy monitor.

func (*Monitor) Start

func (m *Monitor) Start() error

Start receives messages from the proxy server channel indiciating a server has closed or terminated. It marks the metrics proxy server's port as available by removing it from the portsInUse set.

func (*Monitor) Stop

func (m *Monitor) Stop()

Stop closes the metrics proxy monitoring channel.

type Proxy

type Proxy struct {

	// Port is the port that the metrics proxy server listens on.
	Port int
	// Labels are labels used to apply to metrics.
	Labels map[string]string
	// contains filtered or unexported fields
}

Proxy represents a metrics proxy server for getting and serving remote snapshotter metrics.

func NewProxy

func NewProxy(host string, monitor *Monitor, labels map[string]string, dialer func(context.Context, string, string) (net.Conn, error)) (*Proxy, error)

NewProxy creates a new Proxy with initialized HTTP client and port. dialer is used as the DialContext underlying the metrics HTTP client's RoundTripper.

Reference: https://pkg.go.dev/net/http#Transport

func (*Proxy) Serve

func (mp *Proxy) Serve(ctx context.Context) error

Serve starts the metrics proxy server for a single in-VM snapshotter.

func (*Proxy) Shutdown

func (mp *Proxy) Shutdown(ctx context.Context) error

Shutdown shuts down the remote snapshotter metrics proxy server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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