metrics

package
v0.0.0-...-41bf266 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: CC0-1.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewChild

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

NewChild creates a child timer from the parent found within the supplied context

func NewContext

func NewContext(ctx context.Context, t Timer) context.Context

NewContext returns a new Context that carries the provided Timer

func NewParent

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

NewParent creates a parent timer and embeds it into the returned context.

Types

type Timer

type Timer interface {

	// Close cleans up all resources associated with the Timer. If any pending metrics
	// have not been reported, close will flush the result out.
	Close()
	// contains filtered or unexported methods
}

Timer provides methods for timing methods. Typical Usage scenario:

timer := metrics.GetTimer()
defer timer.Close()
ctx := metrics.NewContext(ctx, timer)
ctx, close := metrics.NewParent(ctx)
defer close()
close1 := metrics.NewChild(ctx, "Ingest #1")
// Perform Ingest #1 call
close1()
close2 := metrics.NewChild(ctx, "Ingest #2")
// Perform Ingest #2 call
close2()

func GetTimer

func GetTimer() Timer

Jump to

Keyboard shortcuts

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