Documentation
¶
Overview ¶
Package responsetimeslo contains a MetricsCollector that tracks a SLO metric for circuits.
Index ¶
- type Collector
- type Config
- type Factory
- type Tracker
- func (r *Tracker) Config() Config
- func (r *Tracker) ErrBadRequest(now time.Time, duration time.Duration)
- func (r *Tracker) ErrConcurrencyLimitReject(now time.Time)
- func (r *Tracker) ErrFailure(now time.Time, duration time.Duration)
- func (r *Tracker) ErrInterrupt(now time.Time, duration time.Duration)
- func (r *Tracker) ErrShortCircuit(now time.Time)
- func (r *Tracker) ErrTimeout(now time.Time, duration time.Duration)
- func (r *Tracker) SetConfigThreadSafe(config Config)
- func (r *Tracker) Success(now time.Time, duration time.Duration)
- func (r *Tracker) Var() expvar.Var
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector interface { // Failed the SLO Failed() // Passed the SLO (responded correctly fast enough) Passed() }
Collector can collect metrics about the happy SLO of a request.
type Config ¶
type Config struct { // MaximumHealthyTime is the maximum amount of time a request can take and still be considered healthy MaximumHealthyTime time.Duration }
Config controls how SLO is tracked by default for a Tracker
type Factory ¶
type Factory struct { Config Config ConfigConstructor []func(circuitName string) Config CollectorConstructors []func(circuitName string) Collector }
Factory creates SLO monitors for a circuit
Example ¶
This example creates a SLO tracker that counts failures at less than 20 ms. You will need to provide your own Collectors.
sloTrackerFactory := responsetimeslo.Factory{ Config: responsetimeslo.Config{ // Consider requests faster than 20 ms as passing MaximumHealthyTime: time.Millisecond * 20, }, // Pass in your collector here: for example, statsd CollectorConstructors: nil, } h := circuit.Manager{ DefaultCircuitProperties: []circuit.CommandPropertiesConstructor{sloTrackerFactory.CommandProperties}, } h.MustCreateCircuit("circuit-with-slo")
Output:
func (*Factory) CommandProperties ¶
CommandProperties appends SLO tracking to a circuit
type Tracker ¶
type Tracker struct { MaximumHealthyTime faststats.AtomicInt64 MeetsSLOCount faststats.AtomicInt64 FailsSLOCount faststats.AtomicInt64 Collectors []Collector // contains filtered or unexported fields }
Tracker sets up a response time SLO that has a reasonable meaning for hystrix. Use it for an SLO like "99% of requests should respond correctly within 300 ms".
Define a maximum time that a healthy request is allowed to take. This should be less than the maximum "break" point of the circuit. Only Successful requests <= that time are counted as healthy.
Requests that are interrupted, or have bad input, are not considered healthy or unhealthy. It's like they don't happen. All other types of errors are blamed on the down stream service, or the Run method's request time. They will count as failing the SLA.
func (*Tracker) ErrBadRequest ¶
ErrBadRequest is ignored
func (*Tracker) ErrConcurrencyLimitReject ¶
ErrConcurrencyLimitReject is always a failure
func (*Tracker) ErrFailure ¶
ErrFailure is always a failure
func (*Tracker) ErrInterrupt ¶
ErrInterrupt is only a failure if healthy time has passed
func (*Tracker) ErrShortCircuit ¶
ErrShortCircuit is always a failure
func (*Tracker) ErrTimeout ¶
ErrTimeout is always a failure
func (*Tracker) SetConfigThreadSafe ¶
SetConfigThreadSafe updates the configuration stored in the tracker