1/* 2Copyright 2019 The Kubernetes Authors. 3 4Licensed under the Apache License, Version 2.0 (the "License"); 5you may not use this file except in compliance with the License. 6You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10Unless required by applicable law or agreed to in writing, software 11distributed under the License is distributed on an "AS IS" BASIS, 12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13See the License for the specific language governing permissions and 14limitations under the License. 15*/ 16 17package metrics 18 19// TimedObserver gets informed about the values assigned to a variable 20// `X float64` over time, and reports on the ratio `X/X1`. 21type TimedObserver interface { 22 // Add notes a change to the variable 23 Add(deltaX float64) 24 25 // Set notes a setting of the variable 26 Set(x float64) 27 28 // SetX1 changes the value to use for X1 29 SetX1(x1 float64) 30} 31 32// TimedObserverGenerator creates related observers that are 33// differentiated by a series of label values 34type TimedObserverGenerator interface { 35 Generate(x, x1 float64, labelValues []string) TimedObserver 36} 37 38// TimedObserverPair is a corresponding pair of observers, one for the 39// number of requests waiting in queue(s) and one for the number of 40// requests being executed 41type TimedObserverPair struct { 42 // RequestsWaiting is given observations of the number of currently queued requests 43 RequestsWaiting TimedObserver 44 45 // RequestsExecuting is given observations of the number of requests currently executing 46 RequestsExecuting TimedObserver 47} 48 49// TimedObserverPairGenerator generates pairs 50type TimedObserverPairGenerator interface { 51 Generate(waiting1, executing1 float64, labelValues []string) TimedObserverPair 52} 53