metrics

package
v0.19.786 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTags

func AddTags(tags []string, vals ...string) []string

func AddTagsMap

func AddTagsMap(tags []string, vals map[string]string) []string

func New

func New(v *validator.Validate, opts ...writerOption) (*writer, error)

New returns a default writer, which emits metrics to statsd by default

func NewTallyScope

func NewTallyScope(mw Writer) (tally.Scope, io.Closer)

NewTallyScope creates a new tally scope with the given metrics.Writer as the backend, by way of the TallyReporter wrapper.

Tags to be persisted on all metrics emitted via the returned tally.Scope should be attached to the provided Writer.

The returned io.Closer should be closed when no more telemetry is to be written to the scope.

func SplitTag

func SplitTag(tag string) (string, string)

func ToBoolTag

func ToBoolTag(name string, val bool) string

common conversions to make tagging even easier

func ToStatusTag

func ToStatusTag(status string) []string

func ToStatusTypeTag

func ToStatusTypeTag(status, typ string) []string

func ToTag

func ToTag(name, val string) string

func ToTags

func ToTags(inputs map[string]string, addtlTags ...string) []string

ToTags is a flexible tag creator, which can accept a map (for default tags), and either partial tags or full tags.

For instance, both the following string parameter sets are equivalent: ToTags(defaultTags, "status", "ok", "step:step-2") ToTags(defaultTags, "status", "ok", "step", "step-2") ToTags(defaultTags, "status:ok", "step:step-2")

func WithAddress

func WithAddress(addr string) writerOption

func WithDisable

func WithDisable(disable bool) writerOption

func WithLogger

func WithLogger(log *zap.Logger) writerOption

func WithTagMap

func WithTagMap(tags map[string]string) writerOption

func WithTags

func WithTags(tags ...string) writerOption

Types

type Decr

type Decr struct {
	Name string   `json:"name"`
	Tags []string `json:"tags"`
}

func (Decr) Write

func (m Decr) Write(mw Writer)

type Event

type Event struct {
	Event *statsd.Event `json:"event"`
}

func (Event) Write

func (m Event) Write(mw Writer)

type Gauge

type Gauge struct {
	Name  string   `json:"name"`
	Value float64  `json:"value"`
	Tags  []string `json:"tags"`
}

func (Gauge) Write

func (m Gauge) Write(mw Writer)

type Incr

type Incr struct {
	Name string   `json:"name"`
	Tags []string `json:"tags"`
}

func (Incr) Write

func (m Incr) Write(mw Writer)

type TallyReporter

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

TallyReporter is a wrapper around the metrics.Writer interface that conforms to tally.StatsReporter, allowing us to use the same metrics.Writer implementation for temporal's client, which expects a tally.Scope type TallyReporter metrics.Writer

func (*TallyReporter) Capabilities

func (w *TallyReporter) Capabilities() tally.Capabilities

Capabilities implements tally.StatsReporter.

func (*TallyReporter) Flush

func (w *TallyReporter) Flush()

Flush implements tally.StatsReporter.

func (*TallyReporter) ReportCounter

func (w *TallyReporter) ReportCounter(name string, tags map[string]string, value int64)

func (*TallyReporter) ReportGauge

func (w *TallyReporter) ReportGauge(name string, tags map[string]string, value float64)

ReportGauge implements tally.StatsReporter.

func (*TallyReporter) ReportHistogramDurationSamples

func (w *TallyReporter) ReportHistogramDurationSamples(name string, tags map[string]string, buckets tally.Buckets, bucketLowerBound time.Duration, bucketUpperBound time.Duration, samples int64)

ReportHistogramDurationSamples implements tally.StatsReporter as a no-op.

Tally's interface assumes histograms that are calculated/aggregated client-side. Datadog wants to aggregate histograms in their agent. We could sorta-approximate this by breaking down the input histogram as a series of gauges, but the agent would then smash the data points in the time range together, significantly undermining the fidelity of histogram data.

So, rather than produce potentially bad data that increases noise in our obs platform, we err on the side of just dropping this data. We can always revisit if there's a compelling need for some metrics expressed as histograms that outweights the risk of noise.

func (*TallyReporter) ReportHistogramValueSamples

func (w *TallyReporter) ReportHistogramValueSamples(name string, tags map[string]string, buckets tally.Buckets, bucketLowerBound float64, bucketUpperBound float64, samples int64)

ReportHistogramValueSamples implements tally.StatsReporter as a no-op.

See ReportHistogramDurationSamples for no-op rationale.

func (*TallyReporter) ReportTimer

func (w *TallyReporter) ReportTimer(name string, tags map[string]string, interval time.Duration)

ReportTimer implements tally.StatsReporter.

type Timing

type Timing struct {
	Name  string        `json:"name"`
	Value time.Duration `json:"value" swaggertype:"primitive,integer"`
	Tags  []string      `json:"tags"`
}

func (Timing) Write

func (m Timing) Write(mw Writer)

type Writer

type Writer interface {
	// dogstatsd metrics
	Incr(name string, tags []string)
	Decr(name string, tags []string)
	Timing(name string, value time.Duration, tags []string)
	Gauge(name string, value float64, tags []string)
	Count(name string, value int64, tags []string)

	// datadog specific
	Event(e *statsd.Event)

	Flush()
}

Jump to

Keyboard shortcuts

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