Add sensor reading status metrics
This commit is contained in:
parent
b876de55f9
commit
19afd92dc8
4 changed files with 15 additions and 12 deletions
|
@ -2,6 +2,12 @@
|
|||
|
||||
Control the temperature of your fermentation process.
|
||||
|
||||
# TODO
|
||||
|
||||
* Cooler should not have min runtime, but run till min. temp cool level
|
||||
* E.g. cool until setpoint - 1 degrees is reached
|
||||
* ...or just make the damned PID work
|
||||
|
||||
# Epics
|
||||
|
||||
## Heater/Cooler
|
||||
|
|
|
@ -57,7 +57,7 @@ func loadConfiguration() *controllers.ControllerConfig {
|
|||
}
|
||||
|
||||
func reloadConfiguration(config *controllers.ControllerConfig, ctrl *controllers.ChamberController) {
|
||||
|
||||
log.Printf("Reloading configuration")
|
||||
log.Printf("Ambient sensor: %v", config.Sensor.Ambient)
|
||||
log.Printf("Chamber sensor: %v", config.Sensor.Chamber)
|
||||
log.Printf("Wort sensor : %v", config.Sensor.Wort)
|
||||
|
|
|
@ -31,16 +31,16 @@ var (
|
|||
},
|
||||
)
|
||||
|
||||
TemperatureSensorReadingDurationSeconds = promauto.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
TemperatureSensorReadingStatus = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: "fermentord",
|
||||
Subsystem: "temperature",
|
||||
Name: "sensor_reading_duration_seconds",
|
||||
Help: "Duration of temperature sensor readings.",
|
||||
Buckets: []float64{0.25, 0.5, 0.75, 1, 1.25, 1.5},
|
||||
Name: "sensor_reading_status",
|
||||
Help: "Temperature sensor reading status",
|
||||
},
|
||||
[]string{
|
||||
"sensor",
|
||||
"status",
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -104,14 +104,13 @@ func PollSensors(ctx context.Context, wg *sync.WaitGroup, readingInterval time.D
|
|||
|
||||
func readSensors(hub *sentry.Hub) {
|
||||
for _, sensor := range sensors {
|
||||
start := time.Now()
|
||||
t, err := read(sensor)
|
||||
dur := time.Since(start).Seconds()
|
||||
|
||||
if err != nil {
|
||||
accErrSensor[sensor]++
|
||||
hub.CaptureException(err)
|
||||
log.Printf("Error reading temperature sensor %v: %v", sensor, err)
|
||||
metrics.TemperatureSensorReadingStatus.WithLabelValues(sensor, "failed").Inc()
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -127,11 +126,9 @@ func readSensors(hub *sentry.Hub) {
|
|||
WithLabelValues(sensor).
|
||||
Set(r.Degrees())
|
||||
|
||||
metrics.TemperatureSensorReadingDurationSeconds.
|
||||
WithLabelValues(sensor).
|
||||
Observe(dur)
|
||||
|
||||
C <- r
|
||||
|
||||
metrics.TemperatureSensorReadingStatus.WithLabelValues(sensor, "ok").Inc()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue