metricsviz

package
v0.0.0-...-1ca2bd4 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0, MIT Imports: 24 Imported by: 0

Documentation

Overview

Package metricsviz charts profiling metrics data and renders them to HTML.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMetricData = errors.New("no metrics data found")

ErrNoMetricData is returned when no metrics data is found in logs.

View Source
var Groups = map[GroupName][]MetricName{
	"Network packets": {
		"/netstack/dropped_packets",
		"/netstack/nic/malformed_l4_received_packets",
		"/netstack/nic/tx/packets",
		"/netstack/nic/tx_packets_dropped_no_buffer_space",
		"/netstack/nic/rx/packets",
		"/netstack/nic/disabled_rx/packets",
	},
	"Network throughput": {
		"/netstack/nic/tx/bytes",
		"/netstack/nic/rx/bytes",
		"/netstack/nic/disabled_rx/bytes",
	},
	"IP packets": {
		"/netstack/ip/packets_received",
		"/netstack/ip/disabled_packets_received",
		"/netstack/ip/invalid_addresses_received",
		"/netstack/ip/invalid_source_addresses_received",
		"/netstack/ip/packets_delivered",
		"/netstack/ip/packets_sent",
		"/netstack/ip/outgoing_packet_errors",
		"/netstack/ip/malformed_packets_received",
		"/netstack/ip/malformed_fragments_received",
		"/netstack/ip/iptables/prerouting_dropped",
		"/netstack/ip/iptables/input_dropped",
		"/netstack/ip/iptables/output_dropped",
		"/netstack/ip/options/timestamp_received",
		"/netstack/ip/options/record_route_received",
		"/netstack/ip/options/router_alert_received",
		"/netstack/ip/options/unknown_received",
	},
}

Groups maps metrics which are in the same named group. If more than one metric in a group is in the profiled data, it will be shown on the same graph. A metric may be in multiple groups.

Functions

func FromContainerLogs

func FromContainerLogs(ctx context.Context, testLike testing.TB, container Container)

FromContainerLogs parses a container's logs and reports metrics data found within. The container must be stopped or stoppable by the time this is called.

func FromFile

func FromFile(ctx context.Context, logFile string, logFn func(string, ...any)) error

FromFile reads a file and detects whether it is a profiling metrics log file or a file with GVISOR_METRICS-prefixed lines. Either way, it parses the metrics data and reports it.

func FromNamedContainerLogs

func FromNamedContainerLogs(ctx context.Context, testLike testing.TB, container Container, containerName string)

FromNamedContainerLogs parses a container's logs and reports metrics data found within, making note of the container's name on the results page. The container must be stopped or stoppable by the time this is called.

func FromProfilingMetricsLogFile

func FromProfilingMetricsLogFile(ctx context.Context, testLike testing.TB, logFile string)

FromProfilingMetricsLogFile parses a profiling metrics log file (as created by --profiling-metrics-log) and reports metrics data within.

Types

type Container

type Container interface {
	Stop(context.Context) error
	Status(context.Context) (types.ContainerState, error)
	Logs(context.Context) (string, error)
}

Container represents a container that can be stopped and from which we can get logs.

type Data

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

Data maps metrics and field values to timeseries.

func Parse

func Parse(logs string, hasPrefix bool) (*Data, error)

Parse parses metrics data out of the given logs containing profiling metrics data. If `hasPrefix`, only lines prefixed with `metric.MetricsPrefix` will be parsed. If false, all lines will be parsed, and the prefix will be stripped if it is found. If the log does not contain any metrics data, ErrNoMetricData is returned. If the log does contain data but not all lines can be validated, an error is returned but the returned `*Data` is still populated as much as possible.

func (*Data) ToHTML

func (d *Data) ToHTML(opts HTMLOptions) (string, error)

ToHTML generates an HTML page with charts of the metrics data.

type GroupName

type GroupName string

GroupName is the name of a group of metrics.

type HTMLOptions

type HTMLOptions struct {
	// Title is the title of this set of charts.
	Title string

	// ContainerName is the name of the container for which the metrics were
	// collected. May be empty; usually only specified when there are more
	// than one container involved in a single test or benchmark.
	ContainerName string

	// When is the time at which the measurements were taken.
	When time.Time
}

HTMLOptions are options for generating an HTML page with charts of the metrics data.

type Metric

type Metric struct {
	// Name is the name of the metric.
	Name MetricName
	// Metadata is the metadata of the metric.
	Metadata *mpb.MetricMetadata
}

Metric is the full metadata about a metric.

type MetricAndFields

type MetricAndFields struct {
	// MetricName is the name of the metric.
	MetricName MetricName
	// FieldValues is the comma-concatenated version of the field values.
	FieldValues string
}

MetricAndFields is a metric name and a set of field values.

type MetricName

type MetricName string

MetricName is the name of a metric.

type Point

type Point struct {
	// When is the time at which the value was measured.
	When time.Time
	// Value is the value that was measured at that time.
	Value uint64
}

Point is a single data point at a given time within a time series.

type TimeSeries

type TimeSeries struct {
	// Metric is the metric being measured.
	Metric *Metric
	// Fields is the set of field values of the metric.
	FieldValues map[string]string
	// Data is the timestamped set of data points for this metric and field
	// values.
	Data []Point
}

TimeSeries describes the evolution of a metric (for a given set of field values) over time.

func (*TimeSeries) ChartTitle

func (ts *TimeSeries) ChartTitle() string

ChartTitle returns a string appropriate for using as a chart title when this timeseries is the only metric being shown on a chart.

func (*TimeSeries) String

func (ts *TimeSeries) String() string

String returns the name of the timeseries.

Directories

Path Synopsis
metricsviz_cli visualizes metrics from profiling metrics logs.
metricsviz_cli visualizes metrics from profiling metrics logs.

Jump to

Keyboard shortcuts

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