common

package
v0.0.0-...-c0df949 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// FnPrefix is a constant for "fn_", used as a prefix for span names, field names, Prometheus metric names and Prometheus label names
	FnPrefix = "fn_"

	// FieldnamePrefixHistogram is prefixed to the name of a logged field
	// to denote that it corresponds to a histogram metric
	FieldnamePrefixHistogram = FnPrefix + "histogram_"

	// FieldnamePrefixCounter is prefixed to the name of a logged field
	// to denote that it corresponds to a counter metric
	FieldnamePrefixCounter = FnPrefix + "counter_"

	// FieldnamePrefixGauge is prefixed to the name of a logged field
	// to denote that it corresponds to a gauge metric
	FieldnamePrefixGauge = FnPrefix + "gauge_"

	// SpannameSuffixDummy is suffixed to the name of a tracing span
	// to denote that it has been created solely for the purpose of carrying metric values
	// and is not itself of any interest and should not be converted to a Prometheus duration metric
	SpannameSuffixDummy = "_dummy"
)

Variables

This section is empty.

Functions

func DecrementGauge

func DecrementGauge(ctx context.Context, metric string)

DecrementGauge decrements the specified gauge metric It does this by logging an appropriate field value to a tracing span.

func IncrementCounter

func IncrementCounter(ctx context.Context, metric string)

IncrementCounter increments the specified counter metric It does this by logging an appropriate field value to a tracing span.

func IncrementGauge

func IncrementGauge(ctx context.Context, metric string)

IncrementGauge increments the specified gauge metric It does this by logging an appropriate field value to a tracing span.

func IsTemporary

func IsTemporary(err error) bool

func Logger

func Logger(ctx context.Context) logrus.FieldLogger

Logger returns the structured logger.

func LoggerWithFields

func LoggerWithFields(ctx context.Context, fields logrus.Fields) (context.Context, logrus.FieldLogger)

Attempt at simplifying this whole logger in the context thing Could even make this take a generic map, then the logger that gets returned could be used just like the stdlib too, since it's compatible

func NewRNG

func NewRNG(seed int64) *rand.Rand

func NewSyslogHook

func NewSyslogHook(url *url.URL, prefix string) error

func PublishElapsedTimeHistogram

func PublishElapsedTimeHistogram(ctx context.Context, key string, start, end time.Time)

PublishElapsedTimeToSpan publishes the specifed histogram elapsed time since start It does this by logging an appropriate field value to a tracing span Use this when the current tracing span is long-lived and you want the metric to be visible before it ends

func PublishHistogram

func PublishHistogram(ctx context.Context, key string, value float64)

PublishHistogram publishes the specifed histogram metric It does this by logging an appropriate field value to a tracing span Use this when the current tracing span is long-lived and you want the metric to be visible before it ends

func PublishHistogramToSpan

func PublishHistogramToSpan(span opentracing.Span, key string, value float64)

PublishHistogramToSpan publishes the specifed histogram metric It does this by logging an appropriate field value to the specified tracing span Use this when you don't need to create a new tracing span

func PublishHistograms

func PublishHistograms(ctx context.Context, metrics map[string]float64)

PublishHistograms publishes the specifed histogram metrics It does this by logging appropriate field values to a tracing span Use this when the current tracing span is long-lived and you want the metric to be visible before it ends

func SetLogDest

func SetLogDest(to, prefix string)

func SetLogLevel

func SetLogLevel(ll string)

func WithLogger

func WithLogger(ctx context.Context, l logrus.FieldLogger) context.Context

WithLogger stores the logger.

Types

type Backoff

type Backoff int

func (*Backoff) Sleep

func (b *Backoff) Sleep(ctx context.Context)

type BoxTime

type BoxTime struct{}

func (BoxTime) After

func (BoxTime) After(d time.Duration) <-chan time.Time

func (BoxTime) Now

func (BoxTime) Now() time.Time

func (BoxTime) Sleep

func (BoxTime) Sleep(d time.Duration)

type Clock

type Clock interface {
	Now() time.Time
	Sleep(time.Duration)
	After(time.Duration) <-chan time.Time
}

type Temporary

type Temporary interface {
	Temporary() bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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