NewCovenantSQLCollector returns a new CovenantSQLCollector.
()
| 50 | |
| 51 | // NewCovenantSQLCollector returns a new CovenantSQLCollector. |
| 52 | func NewCovenantSQLCollector() prometheus.Collector { |
| 53 | cc := &CovenantSQLCollector{ |
| 54 | covenantSQLStatHistory: [historyCount]int64{}, |
| 55 | RWMutex: sync.RWMutex{}, |
| 56 | metrics: covenantSQLStatsMetrics{ |
| 57 | { |
| 58 | desc: prometheus.NewDesc( |
| 59 | covenantSQLStatNamespace("db_random"), |
| 60 | "CovenantSQL random", |
| 61 | nil, |
| 62 | nil, |
| 63 | ), |
| 64 | eval: CovenantSQLIdle, |
| 65 | valType: prometheus.GaugeValue, |
| 66 | }, |
| 67 | }, |
| 68 | } |
| 69 | |
| 70 | go func(cc *CovenantSQLCollector) { |
| 71 | for { |
| 72 | cc.updateCovenantSQLStat() |
| 73 | time.Sleep(updateInterval) |
| 74 | } |
| 75 | }(cc) |
| 76 | return cc |
| 77 | } |
| 78 | |
| 79 | // Describe returns all descriptions of the collector. |
| 80 | func (cc *CovenantSQLCollector) Describe(ch chan<- *prometheus.Desc) { |