The "memory fragmentation" value named "memory_ratio" was always
truncated to an integer, so in all likelyhood 0. It didn't work anyway
until the incorrect line termination was fixed in an earlier commit.
Neither could the Psram metric be parsed correctly due to the the same
incorrect line termination.
With this change memory usage is reported in line with Prometheus'
upstream recommendations (https://prometheus.io/docs/practices/naming/).
Labels are no longer used to separate distinct dimensions. Total and
free memory as well as the maximum allocation size are reported as
separate metrics where available while labels are used to differenciate
the separate kinds of memory (heap on all, psram on ESP32).
Label values are now also lowercase on ESP32 to match ESP8266.
Metrics should report their base values, not the result of
a calculation. Therefore the already non-working "fragmentation" metric
is dropped. It can easily be calculated in PromQL instead.
The renaming of metrics and label values makes this a breaking change,
especially on ESP32. With the aforementioned formatting errors which
made them unusable that shouldn't be a problem.
Signed-off-by: Michael Hanselmann <public@hansmi.ch>
Format strings for Prometheus metrics were written manually and the
`# TYPE` lines needed to be kept in sync with actual metrics. As
indicated by the previous commit it wasn't always as consistent as
desired. In addition there was a lot of repetition among the strings
which couldn't be reduced at build time.
With this change utility functions are introduced which eliminate the
need for specifying the same metric name more than once. At the same
time the proper escaping for label values, initially added in commit
16b5f2fe9, is now applied for all labels.
The size of the program shrinks slightly by 212 bytes on ESP8266 in the
"tasmota" configuration with Prometheus enabled and 412 bytes on ESP32
with the "tasmota32" configuration.
Signed-off-by: Michael Hanselmann <public@hansmi.ch>
When built for ESP32 the memory fragmentation metric was incorrectly
terminated (likely a typo). The type information for
"tasmota_global_humidity_percentage" didn't include the "_percentage"
and "tasmota_sensors" wsa incorrect too.
Signed-off-by: Michael Hanselmann <public@hansmi.ch>
Either ESP32 rev1/2 that needs special fixes
`-DHAS_PSRAM_FIX -mfix-esp32-psram-cache-issue -lc-psram-workaround -lm-psram-workaround`
or ESP32-PICO-V3-02 that requires esp-idf 4.4