File: metrics.go

package info (click to toggle)
golang-github-mesos-mesos-go 0.0.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 11,724 kB
  • sloc: makefile: 163
file content (107 lines) | stat: -rw-r--r-- 3,579 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package metrics

import (
	"sync"

	"github.com/prometheus/client_golang/prometheus"
)

const (
	Subsystem = "example_scheduler"
)

// TODO(jdef) time in between offers

var (
	CallErrorCount = prometheus.NewCounterVec(prometheus.CounterOpts{
		Subsystem: Subsystem,
		Name:      "call_error_count",
		Help:      "The number of errors for outgoing calls.",
	}, []string{"type"})
	CallCount = prometheus.NewCounterVec(prometheus.CounterOpts{
		Subsystem: Subsystem,
		Name:      "call_count",
		Help:      "The number of outgoing calls.",
	}, []string{"type"})
	CallLatency = prometheus.NewSummaryVec(prometheus.SummaryOpts{
		Subsystem: Subsystem,
		Name:      "call_latency",
		Help:      "Time to execute various calls, by type.",
	}, []string{"type"})
	EventErrorCount = prometheus.NewCounterVec(prometheus.CounterOpts{
		Subsystem: Subsystem,
		Name:      "event_error_count",
		Help:      "The number of event processing errors.",
	}, []string{"type"})
	EventReceivedCount = prometheus.NewCounterVec(prometheus.CounterOpts{
		Subsystem: Subsystem,
		Name:      "event_received_count",
		Help:      "The number of events received.",
	}, []string{"type"})
	EventReceivedLatency = prometheus.NewSummaryVec(prometheus.SummaryOpts{
		Subsystem: Subsystem,
		Name:      "event_received_latency",
		Help:      "Time to process various events, by type.",
	}, []string{"type"})
	OffersReceived = prometheus.NewCounter(prometheus.CounterOpts{
		Subsystem: Subsystem,
		Name:      "offers_received",
		Help:      "The number of individual offers received.",
	})
	OffersDeclined = prometheus.NewCounter(prometheus.CounterOpts{
		Subsystem: Subsystem,
		Name:      "offers_declined",
		Help:      "The number of offers declined.",
	})
	TasksFinished = prometheus.NewCounter(prometheus.CounterOpts{
		Subsystem: Subsystem,
		Name:      "tasks_finished",
		Help:      "The number of tasks finished.",
	})
	TasksLaunched = prometheus.NewCounter(prometheus.CounterOpts{
		Subsystem: Subsystem,
		Name:      "tasks_launched",
		Help:      "The number of tasks launched.",
	})
	JobStartCount = prometheus.NewCounterVec(prometheus.CounterOpts{
		Subsystem: Subsystem,
		Name:      "job_start_count",
		Help:      "The number of internal background jobs started.",
	}, []string{"job"})
	OfferedResources = prometheus.NewSummaryVec(prometheus.SummaryOpts{
		Subsystem: Subsystem,
		Name:      "offered_resources",
		Help:      "Scalar resources offered by type.",
	}, []string{"type"})
	TasksLaunchedPerOfferCycle = prometheus.NewSummary(prometheus.SummaryOpts{
		Subsystem: Subsystem,
		Name:      "tasks_launched_per_cycle",
		Help:      "Number of tasks launched per-offers cycle (event).",
	})
	ArtifactDownloads = prometheus.NewCounter(prometheus.CounterOpts{
		Subsystem: Subsystem,
		Name:      "artifact_downloads",
		Help:      "The number of artifacts served by the built-in http server.",
	})
)

var registerMetrics sync.Once

func Register() {
	registerMetrics.Do(func() {
		prometheus.MustRegister(CallErrorCount)
		prometheus.MustRegister(CallCount)
		prometheus.MustRegister(CallLatency)
		prometheus.MustRegister(EventErrorCount)
		prometheus.MustRegister(EventReceivedCount)
		prometheus.MustRegister(EventReceivedLatency)
		prometheus.MustRegister(OffersReceived)
		prometheus.MustRegister(OffersDeclined)
		prometheus.MustRegister(JobStartCount)
		prometheus.MustRegister(TasksFinished)
		prometheus.MustRegister(TasksLaunched)
		prometheus.MustRegister(OfferedResources)
		prometheus.MustRegister(TasksLaunchedPerOfferCycle)
		prometheus.MustRegister(ArtifactDownloads)
	})
}