Documentation ¶
Index ¶
- type Gate
- func InstrumentGateDuration(duration prometheus.Observer, g Gate) Gate
- func InstrumentGateInFlight(inflight prometheus.Gauge, g Gate) Gate
- func InstrumentGateTotal(total prometheus.Counter, g Gate) Gate
- func New(reg prometheus.Registerer, maxConcurrent int, opName OperationName) Gate
- func NewNoop() Gate
- type GateFactory
- type Keeperdeprecated
- type OperationName
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Gate ¶
type Gate interface { // Start initiates a new request and waits until it's our turn to fulfill a request. Start(ctx context.Context) error // Done finishes a query. Done() }
Gate controls the maximum number of concurrently running and waiting queries.
Example of use:
g := gate.New(r, 5) if err := g.Start(ctx); err != nil { return } defer g.Done()
func InstrumentGateDuration ¶ added in v0.16.0
func InstrumentGateDuration(duration prometheus.Observer, g Gate) Gate
InstrumentGateDuration instruments the provided Gate to track how much time the request has been waiting in the gate.
func InstrumentGateInFlight ¶ added in v0.16.0
func InstrumentGateInFlight(inflight prometheus.Gauge, g Gate) Gate
InstrumentGateInFlight instruments the provided Gate to track how many requests are currently in flight.
func InstrumentGateTotal ¶ added in v0.31.0
func InstrumentGateTotal(total prometheus.Counter, g Gate) Gate
InstrumentGateTotal instruments the provided Gate to track total requests.
func New ¶ added in v0.16.0
func New(reg prometheus.Registerer, maxConcurrent int, opName OperationName) Gate
New returns an instrumented gate limiting the number of requests being executed concurrently.
The gate implementation is based on the github.com/prometheus/prometheus/util/gate package.
It can be called several times but not with the same registerer otherwise it will panic when trying to register the same metric multiple times.
type GateFactory ¶ added in v0.31.0
type GateFactory interface {
New() Gate
}
func NewGateFactory ¶ added in v0.31.0
func NewGateFactory(reg prometheus.Registerer, maxConcurrent int, opName OperationName) GateFactory
NewGateFactory creates a Gate factory. They act like Gate but each produced Gate acts individually in terms of the limit and they have unified metrics.
type Keeper
deprecated
added in
v0.14.0
type Keeper struct {
// contains filtered or unexported fields
}
Keeper is used to create multiple gates sharing the same metrics.
Deprecated: when Keeper is used to create several gates, the metric tracking the number of in-flight metric isn't meaningful because it is hard to say whether requests are being blocked or not. For clients that call gate.(*Keeper).NewGate only once, it is recommended to use gate.New() instead. Otherwise it is recommended to use the github.com/prometheus/prometheus/util/gate package directly and wrap the returned gate with gate.InstrumentGateDuration().
func NewKeeper
deprecated
added in
v0.14.0
func NewKeeper(reg prometheus.Registerer) *Keeper
NewKeeper creates a new Keeper.
Deprecated: see Keeper.
type OperationName ¶ added in v0.31.0
type OperationName string
const ( Queries OperationName = "queries" Selects OperationName = "selects" Gets OperationName = "gets" Sets OperationName = "sets" WriteRequests OperationName = "write_requests" )