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.
|
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
|
# Epics
|
||||||
|
|
||||||
## Heater/Cooler
|
## Heater/Cooler
|
||||||
|
|
|
@ -57,7 +57,7 @@ func loadConfiguration() *controllers.ControllerConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
func reloadConfiguration(config *controllers.ControllerConfig, ctrl *controllers.ChamberController) {
|
func reloadConfiguration(config *controllers.ControllerConfig, ctrl *controllers.ChamberController) {
|
||||||
|
log.Printf("Reloading configuration")
|
||||||
log.Printf("Ambient sensor: %v", config.Sensor.Ambient)
|
log.Printf("Ambient sensor: %v", config.Sensor.Ambient)
|
||||||
log.Printf("Chamber sensor: %v", config.Sensor.Chamber)
|
log.Printf("Chamber sensor: %v", config.Sensor.Chamber)
|
||||||
log.Printf("Wort sensor : %v", config.Sensor.Wort)
|
log.Printf("Wort sensor : %v", config.Sensor.Wort)
|
||||||
|
|
|
@ -31,16 +31,16 @@ var (
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
TemperatureSensorReadingDurationSeconds = promauto.NewHistogramVec(
|
TemperatureSensorReadingStatus = promauto.NewCounterVec(
|
||||||
prometheus.HistogramOpts{
|
prometheus.CounterOpts{
|
||||||
Namespace: "fermentord",
|
Namespace: "fermentord",
|
||||||
Subsystem: "temperature",
|
Subsystem: "temperature",
|
||||||
Name: "sensor_reading_duration_seconds",
|
Name: "sensor_reading_status",
|
||||||
Help: "Duration of temperature sensor readings.",
|
Help: "Temperature sensor reading status",
|
||||||
Buckets: []float64{0.25, 0.5, 0.75, 1, 1.25, 1.5},
|
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"sensor",
|
"sensor",
|
||||||
|
"status",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -104,14 +104,13 @@ func PollSensors(ctx context.Context, wg *sync.WaitGroup, readingInterval time.D
|
||||||
|
|
||||||
func readSensors(hub *sentry.Hub) {
|
func readSensors(hub *sentry.Hub) {
|
||||||
for _, sensor := range sensors {
|
for _, sensor := range sensors {
|
||||||
start := time.Now()
|
|
||||||
t, err := read(sensor)
|
t, err := read(sensor)
|
||||||
dur := time.Since(start).Seconds()
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
accErrSensor[sensor]++
|
accErrSensor[sensor]++
|
||||||
hub.CaptureException(err)
|
hub.CaptureException(err)
|
||||||
log.Printf("Error reading temperature sensor %v: %v", sensor, err)
|
log.Printf("Error reading temperature sensor %v: %v", sensor, err)
|
||||||
|
metrics.TemperatureSensorReadingStatus.WithLabelValues(sensor, "failed").Inc()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,11 +126,9 @@ func readSensors(hub *sentry.Hub) {
|
||||||
WithLabelValues(sensor).
|
WithLabelValues(sensor).
|
||||||
Set(r.Degrees())
|
Set(r.Degrees())
|
||||||
|
|
||||||
metrics.TemperatureSensorReadingDurationSeconds.
|
|
||||||
WithLabelValues(sensor).
|
|
||||||
Observe(dur)
|
|
||||||
|
|
||||||
C <- r
|
C <- r
|
||||||
|
|
||||||
|
metrics.TemperatureSensorReadingStatus.WithLabelValues(sensor, "ok").Inc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue