metrics

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2019 License: Apache-2.0 Imports: 5 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMiddleware

func NewMiddleware(id string, rec Recorder) goresilience.Middleware

NewMiddleware returns a middleware that will decorate a runner and measure the runner chain itself by setting the recorder on the context so the following runners can get and measure.

Types

type Recorder

type Recorder interface {
	// WithID will set the ID name to the recorde and every metric
	// measured with the obtained recorder will be identified with
	// the name.
	WithID(id string) Recorder
	// ObserveCommandExecution will measure the exeuction of the runner chain.
	ObserveCommandExecution(start time.Time, success bool)
	// IncRetry will increment the number of retries.
	IncRetry()
	// IncTimeout will increment the number of timeouts.
	IncTimeout()
	// IncBulkheadQueued increments the number of queued Funcs to execute.
	IncBulkheadQueued()
	// IncBulkheadProcessed increments the number of processed Funcs to execute.
	IncBulkheadProcessed()
	// IncBulkheadProcessed increments the number of timeouts Funcs waiting  to execute.
	IncBulkheadTimeout()
	// IncCircuitbreakerState increments the number of state change.
	IncCircuitbreakerState(state string)
	// IncChaosInjectedFailure increments the number of times injected failure.
	IncChaosInjectedFailure(kind string)
	// SetConcurrencyLimitInflightExecutions sets the number of executions at a given moment
	// executing and queued for execution.
	SetConcurrencyLimitInflightExecutions(q int)
	// IncConcurrencyLimitResult increments the results obtained by the excutions after aplying the
	// limiter result policy.
	IncConcurrencyLimitResult(result string)
	// SetConcurrencyLimitLimiterLimit sets the current limit the limiter algorithm has calculated.
	SetConcurrencyLimitLimiterLimit(limit int)
}

Recorder knows how to measure different kind of metrics.

var Dummy Recorder = &dummy{}

Dummy is a dummy recorder.

func NewPrometheusRecorder

func NewPrometheusRecorder(reg prometheus.Registerer) Recorder

NewPrometheusRecorder returns a new Recorder that knows how to measure using Prometheus kind metrics.

func RecorderFromContext

func RecorderFromContext(ctx context.Context) (recorder Recorder, ok bool)

RecorderFromContext will get the metrics recorder from the context. If there is not context it will return also a dummy recorder that is safe to use it.

Jump to

Keyboard shortcuts

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