Documentation ¶
Overview ¶
Package rolling contains a MetricsCollector that tracks in memory rolling stats about a circuit.
Index ¶
- type FallbackStats
- func (r *FallbackStats) ErrConcurrencyLimitReject(_ context.Context, now time.Time)
- func (r *FallbackStats) ErrFailure(_ context.Context, now time.Time, _ time.Duration)
- func (r *FallbackStats) SetConfigNotThreadSafe(config FallbackStatsConfig)
- func (r *FallbackStats) Success(_ context.Context, now time.Time, _ time.Duration)
- func (r *FallbackStats) Var() expvar.Var
- type FallbackStatsConfig
- type RunStats
- func (r *RunStats) Config() RunStatsConfig
- func (r *RunStats) ErrBadRequest(_ context.Context, now time.Time, duration time.Duration)
- func (r *RunStats) ErrConcurrencyLimitReject(_ context.Context, now time.Time)
- func (r *RunStats) ErrFailure(_ context.Context, now time.Time, duration time.Duration)
- func (r *RunStats) ErrInterrupt(_ context.Context, now time.Time, duration time.Duration)
- func (r *RunStats) ErrShortCircuit(_ context.Context, now time.Time)
- func (r *RunStats) ErrTimeout(_ context.Context, now time.Time, duration time.Duration)
- func (r *RunStats) ErrorPercentage() float64
- func (r *RunStats) ErrorPercentageAt(now time.Time) float64
- func (r *RunStats) ErrorsAt(now time.Time) int64
- func (r *RunStats) LegitimateAttemptsAt(now time.Time) int64
- func (r *RunStats) SetConfigNotThreadSafe(config RunStatsConfig)
- func (r *RunStats) Success(_ context.Context, now time.Time, duration time.Duration)
- func (r *RunStats) Var() expvar.Var
- type RunStatsConfig
- type StatFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FallbackStats ¶
type FallbackStats struct { Successes faststats.RollingCounter ErrConcurrencyLimitRejects faststats.RollingCounter ErrFailures faststats.RollingCounter }
FallbackStats tracks fallback metrics in rolling buckets
func FindFallbackMetrics ¶
func FindFallbackMetrics(c *circuit.Circuit) *FallbackStats
FindFallbackMetrics searches a circuit for the previously stored fallback stats. Returns nil if never set.
func (*FallbackStats) ErrConcurrencyLimitReject ¶
func (r *FallbackStats) ErrConcurrencyLimitReject(_ context.Context, now time.Time)
ErrConcurrencyLimitReject increments the ErrConcurrencyLimitReject bucket
func (*FallbackStats) ErrFailure ¶
ErrFailure increments the ErrFailure bucket
func (*FallbackStats) SetConfigNotThreadSafe ¶
func (r *FallbackStats) SetConfigNotThreadSafe(config FallbackStatsConfig)
SetConfigNotThreadSafe sets the configuration for fallback stats
func (*FallbackStats) Var ¶
func (r *FallbackStats) Var() expvar.Var
Var allows FallbackStats on expvar
type FallbackStatsConfig ¶
type FallbackStatsConfig struct { // Rolling Stats size is https://github.com/Netflix/Hystrix/wiki/Configuration#metricsrollingstatstimeinmilliseconds RollingStatsDuration time.Duration // Now should simulate time.Now Now func() time.Time // RollingStatsNumBuckets is https://github.com/Netflix/Hystrix/wiki/Configuration#metricsrollingstatsnumbuckets RollingStatsNumBuckets int }
FallbackStatsConfig configures how to track fallback stats
func (*FallbackStatsConfig) Merge ¶
func (r *FallbackStatsConfig) Merge(other FallbackStatsConfig)
Merge this config with another
type RunStats ¶
type RunStats struct { Successes faststats.RollingCounter ErrConcurrencyLimitRejects faststats.RollingCounter ErrFailures faststats.RollingCounter ErrShortCircuits faststats.RollingCounter ErrTimeouts faststats.RollingCounter ErrBadRequests faststats.RollingCounter ErrInterrupts faststats.RollingCounter // It is analogous to https://github.com/Netflix/Hystrix/wiki/Metrics-and-Monitoring#latency-percentiles-hystrixcommandrun-execution-gauge Latencies faststats.RollingPercentile // contains filtered or unexported fields }
RunStats tracks rolling windows of callback counts
func FindCommandMetrics ¶
func FindCommandMetrics(c *circuit.Circuit) *RunStats
FindCommandMetrics searches a circuit for the previously stored run stats. Returns nil if never set.
func (*RunStats) Config ¶
func (r *RunStats) Config() RunStatsConfig
Config returns the current configuration
func (*RunStats) ErrBadRequest ¶
ErrBadRequest increments the ErrBadRequest bucket
func (*RunStats) ErrConcurrencyLimitReject ¶
ErrConcurrencyLimitReject increments the ErrConcurrencyLimitReject bucket
func (*RunStats) ErrFailure ¶
ErrFailure increments the ErrFailure bucket
func (*RunStats) ErrInterrupt ¶
ErrInterrupt increments the ErrInterrupts bucket
func (*RunStats) ErrShortCircuit ¶
ErrShortCircuit increments the ErrShortCircuit bucket
func (*RunStats) ErrTimeout ¶
ErrTimeout increments the ErrTimeout bucket
func (*RunStats) ErrorPercentage ¶
ErrorPercentage returns [0.0 - 1.0] what % of request are considered failing in the rolling window.
func (*RunStats) ErrorPercentageAt ¶
ErrorPercentageAt is [0.0 - 1.0] errors/legitimate
func (*RunStats) ErrorsAt ¶
ErrorsAt returns the # of errors at a moment in time (errors are timeouts and failures)
func (*RunStats) LegitimateAttemptsAt ¶
LegitimateAttemptsAt returns the sum of errors and successes
func (*RunStats) SetConfigNotThreadSafe ¶
func (r *RunStats) SetConfigNotThreadSafe(config RunStatsConfig)
SetConfigNotThreadSafe updates the RunStats buckets
type RunStatsConfig ¶
type RunStatsConfig struct { // Now should simulate time.Now Now func() time.Time // Rolling Stats size is https://github.com/Netflix/Hystrix/wiki/Configuration#metricsrollingstatstimeinmilliseconds RollingStatsDuration time.Duration // RollingStatsNumBuckets is https://github.com/Netflix/Hystrix/wiki/Configuration#metricsrollingstatsnumbuckets RollingStatsNumBuckets int // RollingPercentileDuration is https://github.com/Netflix/Hystrix/wiki/Configuration#metricsrollingpercentiletimeinmilliseconds RollingPercentileDuration time.Duration // RollingPercentileNumBuckets is https://github.com/Netflix/Hystrix/wiki/Configuration#metricsrollingpercentilenumbuckets RollingPercentileNumBuckets int // RollingPercentileBucketSize is https://github.com/Netflix/Hystrix/wiki/Configuration#metricsrollingpercentilebucketsize RollingPercentileBucketSize int }
RunStatsConfig configures a RunStats
func (*RunStatsConfig) Merge ¶
func (r *RunStatsConfig) Merge(other RunStatsConfig)
Merge this config with another
type StatFactory ¶
type StatFactory struct { RunConfig RunStatsConfig FallbackConfig FallbackStatsConfig // contains filtered or unexported fields }
StatFactory helps the process of making stat collectors for circuit breakers
func (*StatFactory) CreateConfig ¶
func (s *StatFactory) CreateConfig(circuitName string) circuit.Config
CreateConfig is a config factory that associates stat collection with the circuit
func (*StatFactory) FallbackStats ¶
func (s *StatFactory) FallbackStats(circuitName string) *FallbackStats
FallbackStats returns the fallback stats for a circuit, or nil if there is none
func (*StatFactory) RunStats ¶
func (s *StatFactory) RunStats(circuitName string) *RunStats
RunStats returns the run stats for a circuit, or nil if there is none