More succbone metrics #14
|
@ -163,16 +163,60 @@ func (s *webServer) viewStream(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
func boolToFloat(b bool) float32 {
|
||||
if b {
|
||||
return 1.0
|
||||
} else {
|
||||
return 0.0
|
||||
}
|
||||
}
|
||||
|
||||
// httpMetrics serves minimalistic Prometheus-compatible metrics.
|
||||
func (s *webServer) viewMetrics(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO(q3k): also serve Go stuff using the actual Prometheus metrics client
|
||||
// library.
|
||||
// TODO(q3k): serve the rest of the data model
|
||||
state := s.d.snapshot()
|
||||
mbar := state.piraniMbar100.mbar
|
||||
|
||||
// sem_pressure_mbar is meant to represent the fused pressure value
|
||||
|
||||
// from all data sources once we have more vacuum sensors in the
|
||||
// system. sem_pirani_mbar is just the reading from the pirani gauge.
|
||||
fmt.Fprintf(w, "# HELP sem_pressure_mbar Pressure in the SEM chamber, in millibar\n")
|
||||
fmt.Fprintf(w, "# TYPE sem_pressure_mbar gauge\n")
|
||||
fmt.Fprintf(w, "sem_pressure_mbar %f\n", mbar)
|
||||
fmt.Fprintf(w, "sem_pressure_mbar %f\n", state.piraniMbar100.mbar)
|
||||
|
||||
fmt.Fprintf(w, "# HELP sem_pirani_mbar Pressure reading by the Pirani gauge, in millibar\n")
|
||||
fmt.Fprintf(w, "# TYPE sem_pirani_mbar gauge\n")
|
||||
fmt.Fprintf(w, "sem_pirani_mbar %f\n", state.piraniMbar100.mbar)
|
||||
|
||||
fmt.Fprintf(w, "# HELP sem_pirani_volts Voltage output from the Pirani gauge, in volts\n")
|
||||
fmt.Fprintf(w, "# TYPE sem_pirani_volts gauge\n")
|
||||
fmt.Fprintf(w, "sem_pirani_volts %f\n", state.piraniVolts100.avg)
|
||||
|
||||
fmt.Fprintf(w, "# HELP sem_pirani_failsafe_active Whether pirani gauge failsafe mode is active (boolean)\n")
|
||||
fmt.Fprintf(w, "# TYPE sem_pirani_failsafe_active gauge\n")
|
||||
fmt.Fprintf(w, "sem_pirani_failsafe_active %f\n", boolToFloat(state.safety.failsafe))
|
||||
rahix marked this conversation as resolved
Outdated
q3k
commented
Probably should be suffixed with Probably should be suffixed with `_enabled` or `_active` (same for DP lockout).
|
||||
|
||||
fmt.Fprintf(w, "# HELP sem_dp_lockout_active Whether diffusion pump lockout is active (boolean)\n")
|
||||
fmt.Fprintf(w, "# TYPE sem_dp_lockout_active gauge\n")
|
||||
fmt.Fprintf(w, "sem_dp_lockout_active %f\n", boolToFloat(state.safety.highPressure))
|
||||
rahix marked this conversation as resolved
Outdated
q3k
commented
If we rename this to If we rename this to `sem_pump_diffusion_...` and `sem_pump_roughing_...` we could then have aggregate metrics on eg. regex `sem_pump_.*_running`.
|
||||
|
||||
fmt.Fprintf(w, "# HELP sem_pump_diffusion_running Whether the diffusion pump is running (boolean)\n")
|
||||
fmt.Fprintf(w, "# TYPE sem_pump_diffusion_running gauge\n")
|
||||
fmt.Fprintf(w, "sem_pump_diffusion_running %f\n", boolToFloat(state.dpOn))
|
||||
|
||||
fmt.Fprintf(w, "# HELP sem_pump_roughing_running Whether the roughing pump is running (boolean)\n")
|
||||
fmt.Fprintf(w, "# TYPE sem_pump_roughing_running gauge\n")
|
||||
fmt.Fprintf(w, "sem_pump_roughing_running %f\n", boolToFloat(state.rpOn))
|
||||
|
||||
rough, high := state.vacuumStatus()
|
||||
fmt.Fprintf(w, "# HELP sem_vacuum_rough_reached Whether a rough vacuum has been reached (boolean)\n")
|
||||
rahix marked this conversation as resolved
Outdated
q3k
commented
`passed` in comment, `reached` in metric name - let's settle on one term?
|
||||
fmt.Fprintf(w, "# TYPE sem_vacuum_rough_reached gauge\n")
|
||||
fmt.Fprintf(w, "sem_vacuum_rough_reached %f\n", boolToFloat(rough))
|
||||
|
||||
fmt.Fprintf(w, "# HELP sem_vacuum_high_reached Whether a high vacuum has been reached (boolean)\n")
|
||||
fmt.Fprintf(w, "# TYPE sem_vacuum_high_reached gauge\n")
|
||||
fmt.Fprintf(w, "sem_vacuum_high_reached %f\n", boolToFloat(high))
|
||||
}
|
||||
|
||||
func (s *webServer) viewRoughingPumpEnable(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
Loading…
Reference in a new issue
Let's wait until we have more data sources and work on the model then - I don't think there's much sense in doing this ahead of time?
My main motivation here was to not break the existing metric but keep consistency in the naming - a
sem_pressure_volts
would not make sense but havingsem_pressure_mbar
alongsidesem_pirani_volts
is also not nice. So by duplicating the metric, the names are consistent and we don't break already recorded metrics data for no good reason.