eventstat

package
v0.0.0-...-47dfa83 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Package eventstat contains helper to create statistics about events with unbounded cardinality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithLimit

func WithLimit(limit int) func(counter *counter)

WithLimit limits the number of the counters stored in the memory.

Types

type ClientOpts

type ClientOpts struct {
	// Interval is how frequently stats from the provided Registry will be
	// sent up. Note that this interval is "jittered", so the actual interval
	// is taken from a normal distribution with a mean of Interval and a
	// variance of Interval/4. Defaults to DefaultInterval.
	Interval time.Duration

	// Application is the application name, usually prepended to metric names.
	// By default it will be os.Args[0].
	Application string

	// Instance is a string that identifies this particular server. Could be a
	// node id, but defaults to the result of DefaultInstanceId().
	Instance string

	// PacketSize controls how we fragment the data as it goes out in UDP
	// packets. Defaults to DefaultPacketSize.
	PacketSize int
}

ClientOpts allows you to set Client Options.

type Publisher

type Publisher func(name string, tags Tags, value float64)

Publisher is a function which sends out statistics.

type Registry

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

Registry represents the collection of different event counters.

func (*Registry) NewTagCounter

func (r *Registry) NewTagCounter(name string, key string, opts ...func(*counter)) Sink

NewTagCounter creates an event counter which is registered to the registry.

func (*Registry) PublishAndReset

func (r *Registry) PublishAndReset(publisher Publisher)

PublishAndReset publishes actual statistics and reset all internal state.

type Sink

type Sink func(name string)

Sink is a function to receive an event.

type Tags

type Tags map[string]string

Tags represent key/values for any event.

func (*Tags) String

func (t *Tags) String() string

type UDPPublisher

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

UDPPublisher is an eventstat telemetry client for sending UDP packets at a regular interval.

func NewUDPPublisher

func NewUDPPublisher(remoteAddr string, registry *Registry, opts ClientOpts) (rv *UDPPublisher, err error)

NewUDPPublisher constructs a telemetry client that sends packets to remoteAddr over UDP.

func (*UDPPublisher) Run

func (c *UDPPublisher) Run(ctx context.Context)

Run calls Report roughly every Interval.

Jump to

Keyboard shortcuts

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