MCPcopy Index your code
hub / github.com/coder/coder / newAgentMetrics

Function newAgentMetrics

agent/metrics.go:25–63  ·  view source on GitHub ↗
(registerer prometheus.Registerer)

Source from the content-addressed store, hash-verified

23}
24
25func newAgentMetrics(registerer prometheus.Registerer) *agentMetrics {
26 connectionsTotal := prometheus.NewCounter(prometheus.CounterOpts{
27 Namespace: "agent", Subsystem: "reconnecting_pty", Name: "connections_total",
28 })
29 registerer.MustRegister(connectionsTotal)
30
31 reconnectingPTYErrors := prometheus.NewCounterVec(
32 prometheus.CounterOpts{
33 Namespace: "agent",
34 Subsystem: "reconnecting_pty",
35 Name: "errors_total",
36 },
37 []string{"error_type"},
38 )
39 registerer.MustRegister(reconnectingPTYErrors)
40
41 startupScriptSeconds := prometheus.NewGaugeVec(prometheus.GaugeOpts{
42 Namespace: "coderd",
43 Subsystem: "agentstats",
44 Name: "startup_script_seconds",
45 Help: "Amount of time taken to run the startup script in seconds.",
46 }, []string{"success"})
47 registerer.MustRegister(startupScriptSeconds)
48
49 currentConnections := prometheus.NewGaugeVec(prometheus.GaugeOpts{
50 Namespace: "coderd",
51 Subsystem: "agentstats",
52 Name: "currently_reachable_peers",
53 Help: "The number of peers (e.g. clients) that are currently reachable over the encrypted network.",
54 }, []string{"connection_type"})
55 registerer.MustRegister(currentConnections)
56
57 return &agentMetrics{
58 connectionsTotal: connectionsTotal,
59 reconnectingPTYErrors: reconnectingPTYErrors,
60 startupScriptSeconds: startupScriptSeconds,
61 currentConnections: currentConnections,
62 }
63}
64
65func (a *agent) collectMetrics(ctx context.Context) []*proto.Stats_Metric {
66 var collected []*proto.Stats_Metric

Callers 1

NewFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected