v2zgo.at/goatcounter/v2/metrics Index | Files

package metrics

import "zgo.at/goatcounter/v2/metrics"

Package metrics collects performance metrics.

Index

Types

type Metric

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

Metric is a single metric that's being recorded.

func Start

func Start(tag string) *Metric

Start recording performance metrics with the given tag.

func (*Metric) AddTag

func (t *Metric) AddTag(tag string)

AddTag adds another part to this metric's tag, for example:

m := Start("hello")
defer m.Done()

if isCached {
    m.AddTag("cached")
    return cachedItem
}

This will record the cached entries as "hello.cached", separate from the regular "hello" entries.

func (*Metric) Done

func (t *Metric) Done()

Done finishes recording this performance metrics, and actually records it.

type Metrics

type Metrics []struct {
	Tag   string
	Times ztime.Durations
}

func List

func List() Metrics

List metrics, sorted by name.

func (Metrics) Sort

func (m Metrics) Sort(metric string) Metrics

Sort returns a copy sorted by the given metric.

Source Files

metrics.go

Version
v2.5.0 (latest)
Published
Dec 14, 2023
Platform
linux/amd64
Imports
5 packages
Last checked
1 day ago

Tools for package owners.