|
15 | 15 |
|
16 | 16 | package collectors |
17 | 17 |
|
18 | | -import "github.com/prometheus/client_golang/prometheus" |
| 18 | +import ( |
| 19 | + "database/sql" |
19 | 20 |
|
20 | | -func (c *dbStatsCollector) describe(ch chan<- *prometheus.Desc) { |
21 | | - ch <- c.maxOpenConnections |
22 | | - ch <- c.openConnections |
23 | | - ch <- c.inUseConnections |
24 | | - ch <- c.idleConnections |
25 | | - ch <- c.waitCount |
26 | | - ch <- c.waitDuration |
27 | | - ch <- c.maxIdleClosed |
| 21 | + "github.com/prometheus/client_golang/prometheus" |
| 22 | +) |
| 23 | + |
| 24 | +func (c *dbStatsCollector) describeNewInGo115(ch chan<- *prometheus.Desc) { |
28 | 25 | ch <- c.maxIdleTimeClosed |
29 | | - ch <- c.maxLifetimeClosed |
30 | 26 | } |
31 | 27 |
|
32 | | -func (c *dbStatsCollector) collect(ch chan<- prometheus.Metric) { |
33 | | - stats := c.db.Stats() |
34 | | - ch <- prometheus.MustNewConstMetric(c.maxOpenConnections, prometheus.GaugeValue, float64(stats.MaxOpenConnections)) |
35 | | - ch <- prometheus.MustNewConstMetric(c.openConnections, prometheus.GaugeValue, float64(stats.OpenConnections)) |
36 | | - ch <- prometheus.MustNewConstMetric(c.inUseConnections, prometheus.GaugeValue, float64(stats.InUse)) |
37 | | - ch <- prometheus.MustNewConstMetric(c.idleConnections, prometheus.GaugeValue, float64(stats.Idle)) |
38 | | - ch <- prometheus.MustNewConstMetric(c.waitCount, prometheus.CounterValue, float64(stats.WaitCount)) |
39 | | - ch <- prometheus.MustNewConstMetric(c.waitDuration, prometheus.CounterValue, stats.WaitDuration.Seconds()) |
40 | | - ch <- prometheus.MustNewConstMetric(c.maxIdleClosed, prometheus.CounterValue, float64(stats.MaxIdleClosed)) |
| 28 | +func (c *dbStatsCollector) collectNewInGo115(ch chan<- prometheus.Metric, stats sql.DBStats) { |
41 | 29 | ch <- prometheus.MustNewConstMetric(c.maxIdleTimeClosed, prometheus.CounterValue, float64(stats.MaxIdleTimeClosed)) |
42 | | - ch <- prometheus.MustNewConstMetric(c.maxLifetimeClosed, prometheus.CounterValue, float64(stats.MaxLifetimeClosed)) |
43 | 30 | } |
0 commit comments