istio

Форк
0
/
metrics.go 
61 строка · 1.9 Кб
1
// Copyright Istio Authors
2
//
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
//
7
//	http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
package queue
16

17
import (
18
	"time"
19

20
	"k8s.io/utils/clock"
21

22
	"istio.io/istio/pilot/pkg/features"
23
	"istio.io/istio/pkg/monitoring"
24
)
25

26
var (
27
	queueIDTag   = monitoring.CreateLabel("queueID")
28
	enableMetric = monitoring.WithEnabled(func() bool {
29
		return features.EnableControllerQueueMetrics
30
	})
31
	depth = monitoring.NewGauge("pilot_worker_queue_depth", "Depth of the controller queues", enableMetric)
32

33
	latency = monitoring.NewDistribution("pilot_worker_queue_latency",
34
		"Latency before the item is processed", []float64{.01, .1, .2, .5, 1, 3, 5}, enableMetric)
35

36
	workDuration = monitoring.NewDistribution("pilot_worker_queue_duration",
37
		"Time taken to process an item", []float64{.01, .1, .2, .5, 1, 3, 5}, enableMetric)
38
)
39

40
type queueMetrics struct {
41
	depth        monitoring.Metric
42
	latency      monitoring.Metric
43
	workDuration monitoring.Metric
44
	id           string
45
	clock        clock.WithTicker
46
}
47

48
// Gets the time since the specified start in seconds.
49
func (m *queueMetrics) sinceInSeconds(start time.Time) float64 {
50
	return m.clock.Since(start).Seconds()
51
}
52

53
func newQueueMetrics(id string) *queueMetrics {
54
	return &queueMetrics{
55
		id:           id,
56
		depth:        depth.With(queueIDTag.Value(id)),
57
		workDuration: workDuration.With(queueIDTag.Value(id)),
58
		latency:      latency.With(queueIDTag.Value(id)),
59
		clock:        clock.RealClock{},
60
	}
61
}
62

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.