stats

package
v0.0.0-...-fb052f6 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package stats tracks staticics for the gomodfs file system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveSpan

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

func (*ActiveSpan) End

func (s *ActiveSpan) End(err error)

type OpStat

type OpStat struct {
	Started  int
	Ended    int
	Errs     int // all errors
	CtxErrs  int // subset of Errs where the ctx is done
	TotalDur time.Duration
}

OpStat holds statistics for a single operation type.

All fields are guarded by the Stats.mu mutex.

func (*OpStat) NumSuccess

func (os *OpStat) NumSuccess() int

NumSuccess returns the number of successful operations.

type Stats

type Stats struct {
	MetricOpStarted  *prometheus.CounterVec // used if non-nil
	MetricOpEnded    *prometheus.CounterVec // used if non-nil
	MetricOpDuration *prometheus.CounterVec // used if non-nil
	// contains filtered or unexported fields
}

Stats holds the operation statistics for the gomodfs file system.

If nil, no statistics are collected.

func NewStatsWithRegistry

func NewStatsWithRegistry(reg *prometheus.Registry) *Stats

NewStatsWithRegstry returns a new Stats instance with metrics initialized and registered to the provided registry.

func (*Stats) Clone

func (st *Stats) Clone() map[string]*OpStat

Clone returns a clone of the current operation statistics, keyed by operation name.

If st is nil, it returns nil. Otherwise it returns a non-nil map.

func (*Stats) ServeHTTP

func (st *Stats) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Stats) StartSpan

func (st *Stats) StartSpan(op string) *ActiveSpan

StartSpan starts a new operation span for the given op.

If s is nil, a non-nil ActiveSpan is returned that does nothing when its End method is called.

Jump to

Keyboard shortcuts

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