statshouse

package module
v0.5.20 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAddr    = "127.0.0.1:13337"
	DefaultNetwork = "tcp"
	// You can add this tag instead of calling StringTop functions family.
	// This is especialy useful, if you are going to send value or unique, as StringTop family is for counters only.
	StringTopTag      = 47
	StringTopNamedTag = "47"
)

Variables

This section is empty.

Functions

func BucketCount

func BucketCount()

func Close

func Close() error

Close calls *Client.Close on the global Client. Make sure to call Close during app exit to avoid losing the last batch of metrics.

func Configure

func Configure(logf LoggerFunc, statsHouseAddr string, defaultEnv string)

Configure is expected to be called once during app startup to configure the global Client. Specifying empty StatsHouse address will make the client silently discard all metrics.

func ConfigureEx

func ConfigureEx(args ConfigureArgs)

func ConfigureNetwork

func ConfigureNetwork(logf LoggerFunc, network string, statsHouseAddr string, defaultEnv string)

network must be either "tcp", "udp" or "unixgram"

func Count

func Count(name string, tags Tags, n float64)

func CountHistoric

func CountHistoric(name string, tags Tags, n float64, tsUnixSec uint32)

func LexDecode

func LexDecode(x int32) float32

func LexEncode

func LexEncode(x float32) int32

Advanced feature. Encodes float as a raw tag in a special format, used by Statshouse. Ordering of all float values is preserved after encoding. Except all NaNs map to single value which is > +inf, and both zeroes map to 0.

func LexEncodeStr

func LexEncodeStr(x float32) string

func NamedCount

func NamedCount(name string, tags NamedTags, n float64)

func NamedCountHistoric

func NamedCountHistoric(name string, tags NamedTags, n float64, tsUnixSec uint32)

func NamedStringTop

func NamedStringTop(name string, tags NamedTags, value string)

func NamedStringTopHistoric

func NamedStringTopHistoric(name string, tags NamedTags, value string, tsUnixSec uint32)

func NamedStringsTop

func NamedStringsTop(name string, tags NamedTags, values []string)

func NamedStringsTopHistoric

func NamedStringsTopHistoric(name string, tags NamedTags, values []string, tsUnixSec uint32)

func NamedUnique

func NamedUnique(name string, tags NamedTags, value int64)

func NamedUniqueHistoric

func NamedUniqueHistoric(name string, tags NamedTags, value int64, tsUnixSec uint32)

func NamedUniques

func NamedUniques(name string, tags NamedTags, values []int64)

func NamedUniquesHistoric

func NamedUniquesHistoric(name string, tags NamedTags, values []int64, tsUnixSec uint32)

func NamedValue

func NamedValue(name string, tags NamedTags, value float64)

func NamedValueHistoric

func NamedValueHistoric(name string, tags NamedTags, value float64, tsUnixSec uint32)

func NamedValues

func NamedValues(name string, tags NamedTags, values []float64)

func NamedValuesHistoric

func NamedValuesHistoric(name string, tags NamedTags, values []float64, tsUnixSec uint32)

func StartRegularMeasurement

func StartRegularMeasurement(f func(*Client)) (id int)

StartRegularMeasurement calls *Client.StartRegularMeasurement on the global Client. It is valid to call StartRegularMeasurement before Configure.

func StopRegularMeasurement

func StopRegularMeasurement(id int)

StopRegularMeasurement calls *Client.StopRegularMeasurement on the global Client. It is valid to call StopRegularMeasurement before Configure.

func StringTop

func StringTop(name string, tags Tags, value string)

func StringTopHistoric

func StringTopHistoric(name string, tags Tags, value string, tsUnixSec uint32)

func StringsTop

func StringsTop(name string, tags Tags, values []string)

func StringsTopHistoric

func StringsTopHistoric(name string, tags Tags, values []string, tsUnixSec uint32)

func TrackBucketCount

func TrackBucketCount()

func Unique

func Unique(name string, tags Tags, value int64)

func UniqueHistoric

func UniqueHistoric(name string, tags Tags, value int64, tsUnixSec uint32)

func Uniques

func Uniques(name string, tags Tags, values []int64)

func Value

func Value(name string, tags Tags, value float64)

func ValueHistoric

func ValueHistoric(name string, tags Tags, value float64, tsUnixSec uint32)

func Values

func Values(name string, tags Tags, values []float64)

func ValuesHistoric

func ValuesHistoric(name string, tags Tags, values []float64, tsUnixSec uint32)

Types

type Client

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

func NewClient

func NewClient(logf LoggerFunc, network string, statsHouseAddr string, defaultEnv string) *Client

NewClient creates a new Client to send metrics. Use NewClient only if you are sending metrics to two or more StatsHouse clusters. Otherwise, simply Configure the default global Client.

Specifying empty StatsHouse address will make the client silently discard all metrics. if you get compiler error after updating to recent version of library, pass statshouse.DefaultNetwork to network parameter

func NewClientEx

func NewClientEx(args ConfigureArgs) *Client

func (*Client) BucketCount

func (c *Client) BucketCount() int32

For debug purposes. Panics if Client.TrackBucketCount wasn't called.

func (*Client) Close

func (c *Client) Close() error

Close the Client and flush unsent metrics to the StatsHouse agent. No data will be sent after Close has returned.

func (*Client) ConfigureEx

func (c *Client) ConfigureEx(args ConfigureArgs)

func (*Client) Count

func (c *Client) Count(name string, tags Tags, n float64)

func (*Client) CountHistoric

func (c *Client) CountHistoric(name string, tags Tags, n float64, tsUnixSec uint32)

func (*Client) Metric deprecated

func (c *Client) Metric(metric string, tags Tags) *MetricRef

Deprecated: causes unnecessary memory allocation. Use either Client.MetricRef or direct write func like Client.Count.

func (*Client) MetricNamed deprecated

func (c *Client) MetricNamed(metric string, tags NamedTags) *MetricRef

Deprecated: causes unnecessary memory allocation. Use either Client.MetricNamedRef or direct write func like Client.Count.

func (*Client) MetricNamedRef

func (c *Client) MetricNamedRef(metric string, tags NamedTags) MetricRef

MetricNamedRef is similar to *Client.MetricRef but slightly slower, and allows to specify tags by name.

func (*Client) MetricRef

func (c *Client) MetricRef(metric string, tags Tags) MetricRef

MetricRef is the preferred way to record observations, save the result for later use:

var countPacketOK = statshouse.GetMetricRef("foo", statshouse.Tags{1: "ok"})
countPacketOK.Count(1)  // lowest overhead possible

func (*Client) NamedCount

func (c *Client) NamedCount(name string, tags NamedTags, n float64)

func (*Client) NamedCountHistoric

func (c *Client) NamedCountHistoric(name string, tags NamedTags, n float64, tsUnixSec uint32)

func (*Client) NamedStringTop

func (c *Client) NamedStringTop(name string, tags NamedTags, value string)

func (*Client) NamedStringTopHistoric

func (c *Client) NamedStringTopHistoric(name string, tags NamedTags, value string, tsUnixSec uint32)

func (*Client) NamedStringsTop

func (c *Client) NamedStringsTop(name string, tags NamedTags, values []string)

func (*Client) NamedStringsTopHistoric

func (c *Client) NamedStringsTopHistoric(name string, tags NamedTags, values []string, tsUnixSec uint32)

func (*Client) NamedUnique

func (c *Client) NamedUnique(name string, tags NamedTags, value int64)

func (*Client) NamedUniqueHistoric

func (c *Client) NamedUniqueHistoric(name string, tags NamedTags, value int64, tsUnixSec uint32)

func (*Client) NamedUniques

func (c *Client) NamedUniques(name string, tags NamedTags, values []int64)

func (*Client) NamedUniquesHistoric

func (c *Client) NamedUniquesHistoric(name string, tags NamedTags, values []int64, tsUnixSec uint32)

func (*Client) NamedValue

func (c *Client) NamedValue(name string, tags NamedTags, value float64)

func (*Client) NamedValueHistoric

func (c *Client) NamedValueHistoric(name string, tags NamedTags, value float64, tsUnixSec uint32)

func (*Client) NamedValues

func (c *Client) NamedValues(name string, tags NamedTags, values []float64)

func (*Client) NamedValuesHistoric

func (c *Client) NamedValuesHistoric(name string, tags NamedTags, values []float64, tsUnixSec uint32)

func (*Client) SetEnv

func (c *Client) SetEnv(env string)

SetEnv changes the default environment associated with Client.

func (*Client) StartRegularMeasurement

func (c *Client) StartRegularMeasurement(f func(*Client)) (id int)

StartRegularMeasurement will call f once per collection interval with no gaps or drift, until StopRegularMeasurement is called with the same ID.

func (*Client) StopRegularMeasurement

func (c *Client) StopRegularMeasurement(id int)

StopRegularMeasurement cancels StartRegularMeasurement with the specified ID.

func (*Client) StringTop

func (c *Client) StringTop(name string, tags Tags, value string)

func (*Client) StringTopHistoric

func (c *Client) StringTopHistoric(name string, tags Tags, value string, tsUnixSec uint32)

func (*Client) StringsTop

func (c *Client) StringsTop(name string, tags Tags, values []string)

func (*Client) StringsTopHistoric

func (c *Client) StringsTopHistoric(name string, tags Tags, values []string, tsUnixSec uint32)

func (*Client) TrackBucketCount

func (c *Client) TrackBucketCount()

For debug purposes. If necessary then it should be first method called on Client.

func (*Client) Unique

func (c *Client) Unique(name string, tags Tags, value int64)

func (*Client) UniqueHistoric

func (c *Client) UniqueHistoric(name string, tags Tags, value int64, tsUnixSec uint32)

func (*Client) Uniques

func (c *Client) Uniques(name string, tags Tags, values []int64)

func (*Client) UniquesHistoric

func (c *Client) UniquesHistoric(name string, tags Tags, values []int64, tsUnixSec uint32)

func (*Client) Value

func (c *Client) Value(name string, tags Tags, value float64)

func (*Client) ValueHistoric

func (c *Client) ValueHistoric(name string, tags Tags, value float64, tsUnixSec uint32)

func (*Client) Values

func (c *Client) Values(name string, tags Tags, values []float64)

func (*Client) ValuesHistoric

func (c *Client) ValuesHistoric(name string, tags Tags, values []float64, tsUnixSec uint32)

type ConfigureArgs

type ConfigureArgs struct {
	Logger         LoggerFunc
	AppName        string
	DefaultEnv     string
	Network        string // default "tcp"
	StatsHouseAddr string // default "127.0.0.1:13337", support comma-separated host:port and dns address
	MaxBucketSize  int    // default 1024
}

type LoggerFunc

type LoggerFunc func(format string, args ...interface{})

type MetricRef

type MetricRef struct {
	SurviveNilWrite bool
	// contains filtered or unexported fields
}

MetricRef pointer is obtained via *Client.Metric or *Client.MetricNamed and is used to record attributes of observed events.

func GetMetricRef

func GetMetricRef(metric string, tags Tags) MetricRef

GetMetricRef calls *Client.MetricRef on the global Client. It is valid to call Metric before Configure.

func Metric deprecated

func Metric(metric string, tags Tags) *MetricRef

Deprecated: causes unnecessary memory allocation. Use either Client.MetricRef or direct write func like Client.Count.

func MetricNamed deprecated

func MetricNamed(metric string, tags NamedTags) *MetricRef

Deprecated: causes unnecessary memory allocation. Use either Client.MetricNamedRef or direct write func like Client.Count.

func MetricNamedRef

func MetricNamedRef(metric string, tags NamedTags) MetricRef

MetricNamedRef calls *Client.MetricNamedRef on the global Client. It is valid to call MetricNamedRef before Configure.

func (*MetricRef) Count

func (m *MetricRef) Count(n float64)

Count records the number of events or observations.

func (*MetricRef) CountHistoric

func (m *MetricRef) CountHistoric(n float64, tsUnixSec uint32)

func (*MetricRef) Equal

func (m *MetricRef) Equal(other MetricRef) bool

func (*MetricRef) IsNil

func (m *MetricRef) IsNil() bool

func (*MetricRef) IsValid

func (m *MetricRef) IsValid() bool

func (*MetricRef) StringTop

func (m *MetricRef) StringTop(value string)

StringTop records the observed value for popularity estimation.

func (*MetricRef) StringTopHistoric

func (m *MetricRef) StringTopHistoric(value string, tsUnixSec uint32)

func (*MetricRef) StringsTop

func (m *MetricRef) StringsTop(values []string)

StringsTop records the observed values for popularity estimation.

func (*MetricRef) StringsTopHistoric

func (m *MetricRef) StringsTopHistoric(values []string, tsUnixSec uint32)

func (*MetricRef) Unique

func (m *MetricRef) Unique(value int64)

Unique records the observed value for cardinality estimation.

func (*MetricRef) UniqueHistoric

func (m *MetricRef) UniqueHistoric(value int64, tsUnixSec uint32)

func (*MetricRef) Uniques

func (m *MetricRef) Uniques(values []int64)

Uniques records the observed values for cardinality estimation.

func (*MetricRef) UniquesHistoric

func (m *MetricRef) UniquesHistoric(values []int64, tsUnixSec uint32)

func (*MetricRef) Value

func (m *MetricRef) Value(value float64)

Value records the observed value for distribution estimation.

func (*MetricRef) ValueHistoric

func (m *MetricRef) ValueHistoric(value float64, tsUnixSec uint32)

func (*MetricRef) Values

func (m *MetricRef) Values(values []float64)

Values records the observed values for distribution estimation.

func (*MetricRef) ValuesHistoric

func (m *MetricRef) ValuesHistoric(values []float64, tsUnixSec uint32)

type NamedTags

type NamedTags [][2]string

NamedTags are used to call *Client.MetricNamed.

type Tags

type Tags [maxTags]string // TODO - refactor all functions to receive []string instead

Tags are used to call *Client.Metric.

Directories

Path Synopsis
internal
basictl
Code generated by vktl/cmd/tlgen2; DO NOT EDIT.
Code generated by vktl/cmd/tlgen2; DO NOT EDIT.

Jump to

Keyboard shortcuts

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