stopwatch

package
v0.65.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metric

type Metric interface {
	Stop()
}

type Stopwatch

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

Stopwatch is designed to measure the time of execution of code fragments. Unlike OpenTelemetry Tracing it is extremely simple and lightweight. Even small fragments can be measured.

There is no means for automatic transferring/collecting data somewhere (storage, etc.) Therefore, you need to explicitly call the Export() or GetValues() method

Stopwatch

  • is not concurrent-safe
  • supports nested metrics
  • supports sampling (in case of frequent measurement of the same metric, for example in a cycle, not all measurements actually occur, in order to save resources)

func New

func New() *Stopwatch

func (*Stopwatch) Export

func (sw *Stopwatch) Export(m *prometheus.HistogramVec, options ...UpdateMetricOption)

func (*Stopwatch) ExportValuesAndCounts

func (sw *Stopwatch) ExportValuesAndCounts(mv, mc *prometheus.HistogramVec, options ...UpdateMetricOption)

func (*Stopwatch) GetCounts

func (sw *Stopwatch) GetCounts() map[string]uint32

func (*Stopwatch) GetValues

func (sw *Stopwatch) GetValues() map[string]time.Duration

func (*Stopwatch) Reset

func (sw *Stopwatch) Reset()

func (*Stopwatch) Start

func (sw *Stopwatch) Start(name string) Metric

func (*Stopwatch) Timer added in v0.62.2

func (sw *Stopwatch) Timer(name string) *Timer

type Timer added in v0.62.2

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

func (*Timer) Start added in v0.62.2

func (t *Timer) Start()

func (*Timer) Stop added in v0.62.2

func (t *Timer) Stop()

type UpdateMetricOption

type UpdateMetricOption func(prometheus.Labels) prometheus.Labels

func SetLabel

func SetLabel(name, value string) UpdateMetricOption

Jump to

Keyboard shortcuts

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