MINOR: stats: Add the support of float fields in stats
It is now possible to format stats counters as floats. But the stats applet does
not use it.
This patch is required by the Prometheus exporter to send the time averages in
seconds. If the promex change is backported, this patch must be backported
first.
diff --git a/include/proto/stats.h b/include/proto/stats.h
index 01c96cb..6144d2f 100644
--- a/include/proto/stats.h
+++ b/include/proto/stats.h
@@ -84,6 +84,12 @@
return f;
}
+static inline struct field mkf_flt(uint32_t type, double value)
+{
+ struct field f = { .type = FF_FLT | type, .u.flt = value };
+ return f;
+}
+
extern const char *stat_status_codes[];
/* These two structs contains all field names according with
diff --git a/include/types/stats.h b/include/types/stats.h
index d99d519..b3a69c6 100644
--- a/include/types/stats.h
+++ b/include/types/stats.h
@@ -198,6 +198,7 @@
FF_S64 = 0x00000003,
FF_U64 = 0x00000004,
FF_STR = 0x00000005,
+ FF_FLT = 0x00000006,
FF_MASK = 0x000000FF,
};
@@ -245,6 +246,7 @@
uint32_t u32; /* FF_U32 */
int64_t s64; /* FF_S64 */
uint64_t u64; /* FF_U64 */
+ double flt; /* FF_FLT */
const char *str; /* FF_STR */
} u;
};