latencies.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. Copyright 2019 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package metrics
  14. import (
  15. "time"
  16. )
  17. const (
  18. // SingleCallTimeout is how long to try single API calls (like 'get' or 'list'). Used to prevent
  19. // transient failures from failing tests.
  20. // TODO: client should not apply this timeout to Watch calls. Increased from 30s until that is fixed.
  21. SingleCallTimeout = 5 * time.Minute
  22. )
  23. // PodLatencyData encapsulates pod startup latency information.
  24. type PodLatencyData struct {
  25. // Name of the pod
  26. Name string
  27. // Node this pod was running on
  28. Node string
  29. // Latency information related to pod startuptime
  30. Latency time.Duration
  31. }
  32. // LatencySlice is an array of PodLatencyData which encapsulates pod startup latency information.
  33. type LatencySlice []PodLatencyData
  34. func (a LatencySlice) Len() int { return len(a) }
  35. func (a LatencySlice) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
  36. func (a LatencySlice) Less(i, j int) bool { return a[i].Latency < a[j].Latency }