forked from DataDog/datadog-process-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprom_telemetry.go
More file actions
28 lines (22 loc) · 784 Bytes
/
prom_telemetry.go
File metadata and controls
28 lines (22 loc) · 784 Bytes
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
package telemetry
import (
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var (
telemetryRegistry = prometheus.NewRegistry()
)
func init() {
telemetryRegistry.MustRegister(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}))
telemetryRegistry.MustRegister(prometheus.NewGoCollector())
}
// Handler serves the HTTP route containing the prometheus metrics.
func Handler() http.Handler {
return promhttp.HandlerFor(telemetryRegistry, promhttp.HandlerOpts{})
}
// Reset resets the global telemetry registry, stopping the collection of every previously registered metrics.
// Mainly used for unit tests and integration tests.
func Reset() {
telemetryRegistry = prometheus.NewRegistry()
}