statsd

package
v1.80.5 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package statsd implements the metrics interface with StatsD.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents the state type of this client.

func New

func New(opts ...Option) (*Client, error)

New creates a new metrics instance with default collectors.

func (*Client) Close

func (c *Client) Close() error

Close method.

func (*Client) IncErrorCounter

func (c *Client) IncErrorCounter(task, operation, code string)

IncErrorCounter increments the number of errors by task, operation and error code.

func (*Client) IncLogLevelCounter

func (c *Client) IncLogLevelCounter(level string)

IncLogLevelCounter counts the number of errors for each log severity level.

func (*Client) InstrumentDB

func (c *Client) InstrumentDB(_ string, _ *sql.DB) error

InstrumentDB wraps a sql.DB to collect metrics - [NOT IMPLEMENTED].

func (*Client) InstrumentHandler

func (c *Client) InstrumentHandler(path string, handler http.HandlerFunc) http.Handler

InstrumentHandler wraps an http.Handler to collect StatsD metrics.

func (*Client) InstrumentRoundTripper

func (c *Client) InstrumentRoundTripper(next http.RoundTripper) http.RoundTripper

InstrumentRoundTripper is a middleware that wraps the provided http.RoundTripper to observe the request result with default metrics.

func (*Client) MetricsHandlerFunc

func (c *Client) MetricsHandlerFunc() http.HandlerFunc

MetricsHandlerFunc returns an http handler function to serve the metrics endpoint. This is not used for the StatsD implementation as the metrics are directly sent to the StatsD server.

type Option

type Option func(c *Client)

Option is the interface that allows to set client options.

func WithAddress

func WithAddress(address string) Option

WithAddress sets the network address of the StatsD daemon (ip:port) or just (:port).

func WithFlushPeriod

func WithFlushPeriod(flushPeriod time.Duration) Option

WithFlushPeriod sets how often the StatsD client's buffer is flushed.

func WithNetwork

func WithNetwork(network string) Option

WithNetwork sets the network type used by the StatsD client (i.e. udp or tcp).

func WithPrefix

func WithPrefix(prefix string) Option

WithPrefix sets the StatsD client's string prefix that will be used in every bucket name.

Jump to

Keyboard shortcuts

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