Run starts the event loop that pushes Prometheus metrics to Graphite at the configured interval.
(ctx context.Context)
| 148 | // Run starts the event loop that pushes Prometheus metrics to Graphite at the |
| 149 | // configured interval. |
| 150 | func (b *Bridge) Run(ctx context.Context) { |
| 151 | ticker := time.NewTicker(b.interval) |
| 152 | defer ticker.Stop() |
| 153 | for { |
| 154 | select { |
| 155 | case <-ticker.C: |
| 156 | if err := b.Push(); err != nil && b.logger != nil { |
| 157 | b.logger.Println("error pushing to Graphite:", err) |
| 158 | } |
| 159 | case <-ctx.Done(): |
| 160 | return |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | // Push pushes Prometheus metrics to the configured Graphite server. |
| 166 | func (b *Bridge) Push() error { |