tally

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 3 Imported by: 29

Documentation

Overview

Package tally implements a MetricsHandler backed by github.com/uber-go/tally.

Index

Constants

This section is empty.

Variables

View Source
var PrometheusSanitizeOptions = tally.SanitizeOptions{
	NameCharacters:       tally.ValidCharacters{Ranges: tally.AlphanumericRange, Characters: []rune{'_'}},
	KeyCharacters:        tally.ValidCharacters{Ranges: tally.AlphanumericRange, Characters: []rune{'_'}},
	ValueCharacters:      tally.ValidCharacters{Ranges: tally.AlphanumericRange, Characters: []rune{'_'}},
	ReplacementCharacter: tally.DefaultReplacementCharacter,
}

PrometheusSanitizeOptions is the set of sanitize options for tally.ScopeOptions to match Prometheus naming rules.

Functions

func NewMetricsHandler

func NewMetricsHandler(scope tally.Scope) client.MetricsHandler

NewMetricsHandler returns a MetricsHandler that is backed by the given Tally scope.

Default metrics are Prometheus compatible, but they should be sanitized and use the Prometheus naming scope so they are cross-SDK compatible with OpenMetrics naming conventions:

opts := tally.ScopeOptions{
	SanitizeOptions: &contribtally.PrometheusSanitizeOptions,
	Separator: "_",
}
scope, _ := tally.NewRootScope(opts, time.Second)
scope = contribtally.NewPrometheusNamingScope(scope)

func NewPrometheusNamingScope added in v0.2.0

func NewPrometheusNamingScope(scope tally.Scope) tally.Scope

NewPrometheusNamingScope makes a scope that appends certain strings to names to conform to OpenMetrics naming standards. This should be used in addition to DefaultPrometheusSanitizeOptions.

func ScopeFromHandler

func ScopeFromHandler(handler client.MetricsHandler) tally.Scope

ScopeFromHandler returns the underlying scope of the handler. Callers may need to check workflow.IsReplaying(ctx) to avoid recording metrics during replay. If this handler was not created via this package, tally.NoopScope is returned.

Raw use of the scope is discouraged but may be used for Histograms or other advanced features. This scope does not skip metrics during replay like the metrics handler does. Therefore the caller should check replay state, for example:

scope := tally.NoopScope
if !workflow.IsReplaying(ctx) {
	scope = ScopeFromHandler(workflow.GetMetricsHandler(ctx))
}
scope.Histogram("my_histogram", nil).RecordDuration(5 * time.Second)

Types

This section is empty.

Jump to

Keyboard shortcuts

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