package metrics

import "github.com/gohugoio/hugo/metrics"

Package metrics provides simple metrics tracking features.

Index

Types

type Provider

type Provider interface {
	// MeasureSince adds a measurement for key to the metric store.
	// Used with defer and time.Now().
	MeasureSince(key string, start time.Time)

	// WriteMetrics will write a summary of the metrics to w.
	WriteMetrics(w io.Writer)

	// TrackValue tracks the value for diff calculations etc.
	TrackValue(key string, value any, cached bool)

	// Reset clears the metric store.
	Reset()
}

The Provider interface defines an interface for measuring metrics.

func NewProvider

func NewProvider(calculateHints bool) Provider

NewProvider returns a new instance of a metric store.

type Store

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

Store provides storage for a set of metrics.

func (*Store) MeasureSince

func (s *Store) MeasureSince(key string, start time.Time)

MeasureSince adds a measurement for key to the metric store.

func (*Store) Reset

func (s *Store) Reset()

Reset clears the metrics store.

func (*Store) TrackValue

func (s *Store) TrackValue(key string, value any, cached bool)

TrackValue tracks the value for diff calculations etc.

func (*Store) WriteMetrics

func (s *Store) WriteMetrics(w io.Writer)

WriteMetrics writes a summary of the metrics to w.

Source Files

metrics.go

Version
v0.144.2 (latest)
Published
Feb 19, 2025
Platform
linux/amd64
Imports
12 packages
Last checked
13 hours ago

Tools for package owners.