metrics

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInt

func AddInt(ctx context.Context, m string, n int, u units.Unit) int

func Child

func Child(ctx context.Context, name string) (context.Context, func())

func Close

func Close(ctx context.Context)

func RenderTree

func RenderTree(buf *bytes.Buffer, x *Collector, indent string) error

RenderTree renders the state of the collector to buf.

func SetDenom

func SetDenom(ctx context.Context, m string, n int, u units.Unit)

func WithCollector

func WithCollector(ctx context.Context, r *Collector) context.Context

Types

type Collector

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

func FromContext

func FromContext(ctx context.Context) *Collector

func NewCollector

func NewCollector() *Collector

NewCollector creates a new root collector

func (*Collector) AddInt

func (r *Collector) AddInt(m string, delta int, u units.Unit) int

func (*Collector) AddInt64

func (r *Collector) AddInt64(m string, delta int64, u units.Unit) (ret int64)

AddInt adds delta to the numerator of metric

func (*Collector) Child

func (r *Collector) Child(name string) *Collector

func (*Collector) Close

func (r *Collector) Close()

func (*Collector) Duration

func (r *Collector) Duration() time.Duration

func (*Collector) GetChild

func (r *Collector) GetChild(id uint) *Collector

func (*Collector) GetCounter

func (r *Collector) GetCounter(m string) *Counter

func (*Collector) IsClosed

func (r *Collector) IsClosed() bool

func (*Collector) List

func (r *Collector) List() []string

func (*Collector) ListChildren

func (r *Collector) ListChildren() []uint

func (*Collector) Name

func (r *Collector) Name() string

func (*Collector) SetDenom

func (r *Collector) SetDenom(m string, x int64, u units.Unit)

func (*Collector) SetInt64

func (r *Collector) SetInt64(m string, x int64, u units.Unit)

type Counter

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

func (*Counter) Absorb

func (c *Counter) Absorb(c2 *Counter)

func (*Counter) Add

func (c *Counter) Add(now time.Time, d int64, u units.Unit) int64

func (*Counter) Get

func (c *Counter) Get() Value

func (*Counter) GetDelta

func (c *Counter) GetDelta() Value

func (*Counter) GetDenom

func (c *Counter) GetDenom() Value

func (*Counter) Set

func (c *Counter) Set(now time.Time, x int64, u units.Unit)

func (*Counter) SetDenom

func (c *Counter) SetDenom(x int64, u units.Unit)

func (*Counter) String

func (c *Counter) String() string

type Renderer

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

func NewTTYRenderer

func NewTTYRenderer(s *Collector, out io.Writer) *Renderer

func (*Renderer) Close

func (r *Renderer) Close() error

type Summary

type Summary struct {
	Name    string
	StartAt time.Time
	EndAt   time.Time
	Metrics map[string]Value
}

Summary is a summary of a completed task

func (*Summary) Elapsed

func (s *Summary) Elapsed() time.Duration

func (*Summary) GetDelta

func (s *Summary) GetDelta(k string) float64

func (*Summary) String

func (s *Summary) String() string

type Value

type Value struct {
	X     float64
	Units units.Unit
}

func (Value) String

func (v Value) String() string

Jump to

Keyboard shortcuts

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