mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Remove the PairVec types
This commit is contained in:
parent
867b5cc31b
commit
1f1cfba2a3
@ -102,7 +102,7 @@ type configController struct {
|
|||||||
name string // varies in tests of fighting controllers
|
name string // varies in tests of fighting controllers
|
||||||
clock clock.PassiveClock
|
clock clock.PassiveClock
|
||||||
queueSetFactory fq.QueueSetFactory
|
queueSetFactory fq.QueueSetFactory
|
||||||
reqsGaugePairVec metrics.RatioedGaugePairVec
|
reqsGaugeVec metrics.RatioedGaugeVec
|
||||||
execSeatsGaugeVec metrics.RatioedGaugeVec
|
execSeatsGaugeVec metrics.RatioedGaugeVec
|
||||||
|
|
||||||
// How this controller appears in an ObjectMeta ManagedFieldsEntry.Manager
|
// How this controller appears in an ObjectMeta ManagedFieldsEntry.Manager
|
||||||
@ -205,7 +205,7 @@ func newTestableController(config TestableConfig) *configController {
|
|||||||
name: config.Name,
|
name: config.Name,
|
||||||
clock: config.Clock,
|
clock: config.Clock,
|
||||||
queueSetFactory: config.QueueSetFactory,
|
queueSetFactory: config.QueueSetFactory,
|
||||||
reqsGaugePairVec: config.ReqsGaugePairVec,
|
reqsGaugeVec: config.ReqsGaugeVec,
|
||||||
execSeatsGaugeVec: config.ExecSeatsGaugeVec,
|
execSeatsGaugeVec: config.ExecSeatsGaugeVec,
|
||||||
asFieldManager: config.AsFieldManager,
|
asFieldManager: config.AsFieldManager,
|
||||||
foundToDangling: config.FoundToDangling,
|
foundToDangling: config.FoundToDangling,
|
||||||
@ -539,7 +539,7 @@ func (meal *cfgMeal) digestNewPLsLocked(newPLs []*flowcontrol.PriorityLevelConfi
|
|||||||
state := meal.cfgCtlr.priorityLevelStates[pl.Name]
|
state := meal.cfgCtlr.priorityLevelStates[pl.Name]
|
||||||
if state == nil {
|
if state == nil {
|
||||||
labelValues := []string{pl.Name}
|
labelValues := []string{pl.Name}
|
||||||
state = &priorityLevelState{reqsGaugePair: meal.cfgCtlr.reqsGaugePairVec.NewForLabelValuesSafe(1, 1, labelValues), execSeatsObs: meal.cfgCtlr.execSeatsGaugeVec.NewForLabelValuesSafe(0, 1, labelValues)}
|
state = &priorityLevelState{reqsGaugePair: metrics.RatioedGaugeVecPhasedElementPair(meal.cfgCtlr.reqsGaugeVec, 1, 1, labelValues), execSeatsObs: meal.cfgCtlr.execSeatsGaugeVec.NewForLabelValuesSafe(0, 1, labelValues)}
|
||||||
}
|
}
|
||||||
qsCompleter, err := queueSetCompleterForPL(meal.cfgCtlr.queueSetFactory, state.queues, pl, meal.cfgCtlr.requestWaitLimit, state.reqsGaugePair, state.execSeatsObs)
|
qsCompleter, err := queueSetCompleterForPL(meal.cfgCtlr.queueSetFactory, state.queues, pl, meal.cfgCtlr.requestWaitLimit, state.reqsGaugePair, state.execSeatsObs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -769,7 +769,7 @@ func (meal *cfgMeal) presyncFlowSchemaStatus(fs *flowcontrol.FlowSchema, isDangl
|
|||||||
func (meal *cfgMeal) imaginePL(proto *flowcontrol.PriorityLevelConfiguration, requestWaitLimit time.Duration) {
|
func (meal *cfgMeal) imaginePL(proto *flowcontrol.PriorityLevelConfiguration, requestWaitLimit time.Duration) {
|
||||||
klog.V(3).Infof("No %s PriorityLevelConfiguration found, imagining one", proto.Name)
|
klog.V(3).Infof("No %s PriorityLevelConfiguration found, imagining one", proto.Name)
|
||||||
labelValues := []string{proto.Name}
|
labelValues := []string{proto.Name}
|
||||||
reqsGaugePair := meal.cfgCtlr.reqsGaugePairVec.NewForLabelValuesSafe(1, 1, labelValues)
|
reqsGaugePair := metrics.RatioedGaugeVecPhasedElementPair(meal.cfgCtlr.reqsGaugeVec, 1, 1, labelValues)
|
||||||
execSeatsObs := meal.cfgCtlr.execSeatsGaugeVec.NewForLabelValuesSafe(0, 1, labelValues)
|
execSeatsObs := meal.cfgCtlr.execSeatsGaugeVec.NewForLabelValuesSafe(0, 1, labelValues)
|
||||||
qsCompleter, err := queueSetCompleterForPL(meal.cfgCtlr.queueSetFactory, nil, proto, requestWaitLimit, reqsGaugePair, execSeatsObs)
|
qsCompleter, err := queueSetCompleterForPL(meal.cfgCtlr.queueSetFactory, nil, proto, requestWaitLimit, reqsGaugePair, execSeatsObs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -100,7 +100,7 @@ func New(
|
|||||||
FlowcontrolClient: flowcontrolClient,
|
FlowcontrolClient: flowcontrolClient,
|
||||||
ServerConcurrencyLimit: serverConcurrencyLimit,
|
ServerConcurrencyLimit: serverConcurrencyLimit,
|
||||||
RequestWaitLimit: requestWaitLimit,
|
RequestWaitLimit: requestWaitLimit,
|
||||||
ReqsGaugePairVec: metrics.PriorityLevelConcurrencyPairVec,
|
ReqsGaugeVec: metrics.PriorityLevelConcurrencyGaugeVec,
|
||||||
ExecSeatsGaugeVec: metrics.PriorityLevelExecutionSeatsGaugeVec,
|
ExecSeatsGaugeVec: metrics.PriorityLevelExecutionSeatsGaugeVec,
|
||||||
QueueSetFactory: fqs.NewQueueSetFactory(clk),
|
QueueSetFactory: fqs.NewQueueSetFactory(clk),
|
||||||
})
|
})
|
||||||
@ -140,8 +140,8 @@ type TestableConfig struct {
|
|||||||
// RequestWaitLimit configured on the server
|
// RequestWaitLimit configured on the server
|
||||||
RequestWaitLimit time.Duration
|
RequestWaitLimit time.Duration
|
||||||
|
|
||||||
// GaugePairVec for metrics about requests
|
// GaugeVec for metrics about requests, broken down by phase and priority_level
|
||||||
ReqsGaugePairVec metrics.RatioedGaugePairVec
|
ReqsGaugeVec metrics.RatioedGaugeVec
|
||||||
|
|
||||||
// RatioedGaugePairVec for metrics about seats occupied by all phases of execution
|
// RatioedGaugePairVec for metrics about seats occupied by all phases of execution
|
||||||
ExecSeatsGaugeVec metrics.RatioedGaugeVec
|
ExecSeatsGaugeVec metrics.RatioedGaugeVec
|
||||||
|
@ -261,7 +261,7 @@ func TestConfigConsumer(t *testing.T) {
|
|||||||
FlowcontrolClient: flowcontrolClient,
|
FlowcontrolClient: flowcontrolClient,
|
||||||
ServerConcurrencyLimit: 100, // server concurrency limit
|
ServerConcurrencyLimit: 100, // server concurrency limit
|
||||||
RequestWaitLimit: time.Minute, // request wait limit
|
RequestWaitLimit: time.Minute, // request wait limit
|
||||||
ReqsGaugePairVec: metrics.PriorityLevelConcurrencyPairVec,
|
ReqsGaugeVec: metrics.PriorityLevelConcurrencyGaugeVec,
|
||||||
ExecSeatsGaugeVec: metrics.PriorityLevelExecutionSeatsGaugeVec,
|
ExecSeatsGaugeVec: metrics.PriorityLevelExecutionSeatsGaugeVec,
|
||||||
QueueSetFactory: cts,
|
QueueSetFactory: cts,
|
||||||
})
|
})
|
||||||
@ -393,7 +393,7 @@ func TestAPFControllerWithGracefulShutdown(t *testing.T) {
|
|||||||
FlowcontrolClient: flowcontrolClient,
|
FlowcontrolClient: flowcontrolClient,
|
||||||
ServerConcurrencyLimit: 100,
|
ServerConcurrencyLimit: 100,
|
||||||
RequestWaitLimit: time.Minute,
|
RequestWaitLimit: time.Minute,
|
||||||
ReqsGaugePairVec: metrics.PriorityLevelConcurrencyPairVec,
|
ReqsGaugeVec: metrics.PriorityLevelConcurrencyGaugeVec,
|
||||||
ExecSeatsGaugeVec: metrics.PriorityLevelExecutionSeatsGaugeVec,
|
ExecSeatsGaugeVec: metrics.PriorityLevelExecutionSeatsGaugeVec,
|
||||||
QueueSetFactory: cts,
|
QueueSetFactory: cts,
|
||||||
})
|
})
|
||||||
|
@ -1462,7 +1462,7 @@ func newFIFO(requests ...*request) fifo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newGaugePair(clk clock.PassiveClock) metrics.RatioedGaugePair {
|
func newGaugePair(clk clock.PassiveClock) metrics.RatioedGaugePair {
|
||||||
return metrics.PriorityLevelConcurrencyPairVec.NewForLabelValuesSafe(1, 1, []string{"test"})
|
return metrics.RatioedGaugeVecPhasedElementPair(metrics.PriorityLevelConcurrencyGaugeVec, 1, 1, []string{"test"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func newExecSeatsGauge(clk clock.PassiveClock) metrics.RatioedGauge {
|
func newExecSeatsGauge(clk clock.PassiveClock) metrics.RatioedGauge {
|
||||||
|
@ -57,7 +57,7 @@ func genPL(rng *rand.Rand, name string) *flowcontrol.PriorityLevelConfiguration
|
|||||||
QueueLengthLimit: 5}
|
QueueLengthLimit: 5}
|
||||||
}
|
}
|
||||||
labelVals := []string{"test"}
|
labelVals := []string{"test"}
|
||||||
_, err := queueSetCompleterForPL(noRestraintQSF, nil, plc, time.Minute, metrics.PriorityLevelConcurrencyPairVec.NewForLabelValuesSafe(1, 1, labelVals), metrics.PriorityLevelExecutionSeatsGaugeVec.NewForLabelValuesSafe(0, 1, labelVals))
|
_, err := queueSetCompleterForPL(noRestraintQSF, nil, plc, time.Minute, metrics.RatioedGaugeVecPhasedElementPair(metrics.PriorityLevelConcurrencyGaugeVec, 1, 1, labelVals), metrics.PriorityLevelExecutionSeatsGaugeVec.NewForLabelValuesSafe(0, 1, labelVals))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -65,14 +65,3 @@ type RatioedGaugePair struct {
|
|||||||
// RequestsExecuting is given observations of the number of requests currently executing
|
// RequestsExecuting is given observations of the number of requests currently executing
|
||||||
RequestsExecuting RatioedGauge
|
RequestsExecuting RatioedGauge
|
||||||
}
|
}
|
||||||
|
|
||||||
// RatioedGaugePairVec generates pairs
|
|
||||||
type RatioedGaugePairVec interface {
|
|
||||||
// NewForLabelValuesSafe makes a new vector member for the given tuple of label values,
|
|
||||||
// initialized with the given denominators and zeros for numerators.
|
|
||||||
// Unlike the usual Vec WithLabelValues method, this is intended to be called only
|
|
||||||
// once per vector member (at the start of its lifecycle).
|
|
||||||
// The "Safe" part is saying that the returned object will function properly after metric registration
|
|
||||||
// even if this method is called before registration.
|
|
||||||
NewForLabelValuesSafe(initialWaitingDenominator, initialExecutingDenominator float64, labelValues []string) RatioedGaugePair
|
|
||||||
}
|
|
||||||
|
@ -127,8 +127,8 @@ var (
|
|||||||
},
|
},
|
||||||
[]string{priorityLevel},
|
[]string{priorityLevel},
|
||||||
)
|
)
|
||||||
// PriorityLevelConcurrencyPairVec creates pairs that observe concurrency for priority levels
|
// PriorityLevelConcurrencyGaugeVec creates gauges of concurrency broken down by phase, priority level
|
||||||
PriorityLevelConcurrencyPairVec = NewSampleAndWaterMarkHistogramsPairVec(clock.RealClock{}, time.Millisecond,
|
PriorityLevelConcurrencyGaugeVec = NewSampleAndWaterMarkHistogramsVec(clock.RealClock{}, time.Millisecond,
|
||||||
&compbasemetrics.HistogramOpts{
|
&compbasemetrics.HistogramOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Subsystem: subsystem,
|
Subsystem: subsystem,
|
||||||
@ -145,7 +145,7 @@ var (
|
|||||||
Buckets: []float64{0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1},
|
Buckets: []float64{0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1},
|
||||||
StabilityLevel: compbasemetrics.ALPHA,
|
StabilityLevel: compbasemetrics.ALPHA,
|
||||||
},
|
},
|
||||||
[]string{priorityLevel},
|
[]string{LabelNamePhase, priorityLevel},
|
||||||
)
|
)
|
||||||
// ReadWriteConcurrencyGaugeVec creates gauges of number of requests broken down by phase and mutating vs readonly
|
// ReadWriteConcurrencyGaugeVec creates gauges of number of requests broken down by phase and mutating vs readonly
|
||||||
ReadWriteConcurrencyGaugeVec = NewSampleAndWaterMarkHistogramsVec(clock.RealClock{}, time.Millisecond,
|
ReadWriteConcurrencyGaugeVec = NewSampleAndWaterMarkHistogramsVec(clock.RealClock{}, time.Millisecond,
|
||||||
@ -356,7 +356,7 @@ var (
|
|||||||
apiserverDispatchWithNoAccommodation,
|
apiserverDispatchWithNoAccommodation,
|
||||||
}.
|
}.
|
||||||
Append(PriorityLevelExecutionSeatsGaugeVec.metrics()...).
|
Append(PriorityLevelExecutionSeatsGaugeVec.metrics()...).
|
||||||
Append(PriorityLevelConcurrencyPairVec.metrics()...).
|
Append(PriorityLevelConcurrencyGaugeVec.metrics()...).
|
||||||
Append(ReadWriteConcurrencyGaugeVec.metrics()...)
|
Append(ReadWriteConcurrencyGaugeVec.metrics()...)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -34,33 +34,6 @@ const (
|
|||||||
LabelValueExecuting = "executing"
|
LabelValueExecuting = "executing"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SampleAndWaterMarkPairVec makes pairs of RatioedGauges that
|
|
||||||
// track samples and watermarks.
|
|
||||||
type SampleAndWaterMarkPairVec struct {
|
|
||||||
urVec SampleAndWaterMarkObserverVec
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ RatioedGaugePairVec = SampleAndWaterMarkPairVec{}
|
|
||||||
|
|
||||||
// NewSampleAndWaterMarkHistogramsPairVec makes a new pair generator
|
|
||||||
func NewSampleAndWaterMarkHistogramsPairVec(clock clock.PassiveClock, samplePeriod time.Duration, sampleOpts, waterMarkOpts *compbasemetrics.HistogramOpts, labelNames []string) SampleAndWaterMarkPairVec {
|
|
||||||
return SampleAndWaterMarkPairVec{
|
|
||||||
urVec: NewSampleAndWaterMarkHistogramsVec(clock, samplePeriod, sampleOpts, waterMarkOpts, append([]string{LabelNamePhase}, labelNames...)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewForLabelValuesSafe makes a new pair
|
|
||||||
func (spg SampleAndWaterMarkPairVec) NewForLabelValuesSafe(initialWaitingDenominator, initialExecutingDenominator float64, labelValues []string) RatioedGaugePair {
|
|
||||||
return RatioedGaugePair{
|
|
||||||
RequestsWaiting: spg.urVec.NewForLabelValuesSafe(0, initialWaitingDenominator, append([]string{LabelValueWaiting}, labelValues...)),
|
|
||||||
RequestsExecuting: spg.urVec.NewForLabelValuesSafe(0, initialExecutingDenominator, append([]string{LabelValueExecuting}, labelValues...)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (spg SampleAndWaterMarkPairVec) metrics() Registerables {
|
|
||||||
return spg.urVec.metrics()
|
|
||||||
}
|
|
||||||
|
|
||||||
// SampleAndWaterMarkObserverVec creates RatioedGauges that
|
// SampleAndWaterMarkObserverVec creates RatioedGauges that
|
||||||
// populate histograms of samples and low- and high-water-marks. The
|
// populate histograms of samples and low- and high-water-marks. The
|
||||||
// generator has a samplePeriod, and the histograms get an observation
|
// generator has a samplePeriod, and the histograms get an observation
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2019 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package metrics
|
||||||
|
|
||||||
|
// RatioedGaugeVecPhasedElementPair extracts a pair of elements that differ in handling phase
|
||||||
|
func RatioedGaugeVecPhasedElementPair(vec RatioedGaugeVec, initialWaitingDenominator, initialExecutingDenominator float64, labelValues []string) RatioedGaugePair {
|
||||||
|
return RatioedGaugePair{
|
||||||
|
RequestsWaiting: vec.NewForLabelValuesSafe(0, initialWaitingDenominator, append([]string{LabelValueWaiting}, labelValues...)),
|
||||||
|
RequestsExecuting: vec.NewForLabelValuesSafe(0, initialExecutingDenominator, append([]string{LabelValueExecuting}, labelValues...)),
|
||||||
|
}
|
||||||
|
}
|
@ -139,7 +139,7 @@ func (ft *fightTest) createController(invert bool, i int) {
|
|||||||
FlowcontrolClient: fcIfc,
|
FlowcontrolClient: fcIfc,
|
||||||
ServerConcurrencyLimit: 200, // server concurrency limit
|
ServerConcurrencyLimit: 200, // server concurrency limit
|
||||||
RequestWaitLimit: time.Minute / 4, // request wait limit
|
RequestWaitLimit: time.Minute / 4, // request wait limit
|
||||||
ReqsGaugePairVec: metrics.PriorityLevelConcurrencyPairVec,
|
ReqsGaugeVec: metrics.PriorityLevelConcurrencyGaugeVec,
|
||||||
ExecSeatsGaugeVec: metrics.PriorityLevelExecutionSeatsGaugeVec,
|
ExecSeatsGaugeVec: metrics.PriorityLevelExecutionSeatsGaugeVec,
|
||||||
QueueSetFactory: fqtesting.NewNoRestraintFactory(),
|
QueueSetFactory: fqtesting.NewNoRestraintFactory(),
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user