removed the init method in prometheuis.go
This commit is contained in:
parent
dfdea81c20
commit
8ef0785165
@ -159,12 +159,35 @@ func clientActive(client models.Client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setupPrometheus(mux *http.ServeMux, notifications chan *models.State) {
|
func setupPrometheus(mux *http.ServeMux, notifications chan *models.State) {
|
||||||
|
// go routine that handles incoming events so we don't need to serialize access in some
|
||||||
|
// other way.
|
||||||
|
go func() {
|
||||||
|
for task := range prometheusChannel {
|
||||||
|
task()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// send an event periodically to update the agent and client durations so
|
||||||
|
// prometheus gets accurate values.
|
||||||
|
go func() {
|
||||||
|
timer := time.NewTicker(1 * time.Second)
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-timer.C:
|
||||||
|
prometheusChannel <- updateDurations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// process incoming notifications from converge to update metrics.
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
state := <-notifications
|
state := <-notifications
|
||||||
updateMetrics(state)
|
updateMetrics(state)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
// expose prometheus on a separate port.
|
||||||
mux.Handle("/metrics", promhttp.Handler())
|
mux.Handle("/metrics", promhttp.Handler())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,24 +214,6 @@ func updateDurations() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
go func() {
|
|
||||||
timer := time.NewTicker(1 * time.Second)
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-timer.C:
|
|
||||||
prometheusChannel <- updateDurations
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
for task := range prometheusChannel {
|
|
||||||
task()
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
func updateMetricsImpl(state *models.State) {
|
func updateMetricsImpl(state *models.State) {
|
||||||
// This implemnetation has a small probability that the metric will be in a partially
|
// This implemnetation has a small probability that the metric will be in a partially
|
||||||
// initialized state. This is however unlikely. It would lead to in incorrect determination
|
// initialized state. This is however unlikely. It would lead to in incorrect determination
|
||||||
|
Loading…
Reference in New Issue
Block a user