コード例 #1
0
ファイル: http.go プロジェクト: JohnnyLe/freegeoip
func ConnStateMetrics(g prometheus.Gauge) ConnStateFunc {
	return func(c net.Conn, s http.ConnState) {
		switch s {
		case http.StateNew:
			g.Inc()
		case http.StateClosed:
			g.Dec()
		}
	}
}
コード例 #2
0
func readGauge(m prometheus.Gauge) float64 {
	// TODO: Revisit this once client_golang offers better testing tools.
	pb := &dto.Metric{}
	m.Write(pb)
	return pb.GetGauge().GetValue()
}