about summary refs log tree commit diff
path: root/diskstats.c
diff options
context:
space:
mode:
authorHeikki Kallasjoki <fis@zem.fi>2018-12-07 02:12:32 +0000
committerHeikki Kallasjoki <fis+github@zem.fi>2018-12-07 02:17:55 +0000
commit7ec8aa9fcfba92019f537cd19dac4ce15674ddd6 (patch)
treeedfdfcb09dd20e54f9cd4742346c1bf8a45e60d2 /diskstats.c
parent16d61af28bcd07348117fd457b62ff39c1a0b45d (diff)
downloadnano-exporter-7ec8aa9fcfba92019f537cd19dac4ce15674ddd6.tar.gz
nano-exporter-7ec8aa9fcfba92019f537cd19dac4ce15674ddd6.tar.xz
nano-exporter-7ec8aa9fcfba92019f537cd19dac4ce15674ddd6.zip
Use a struct type for metric labels.
Resolves #4.

The real readability benefits are for test code, which will follow up in due course.
Diffstat (limited to 'diskstats.c')
-rw-r--r--diskstats.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/diskstats.c b/diskstats.c
index e622fd3..81231aa 100644
--- a/diskstats.c
+++ b/diskstats.c
@@ -95,9 +95,9 @@ static void diskstats_collect(scrape_req *req, void *ctx_ptr) {
 
   // buffers
 
-  const char *labels[][2] = {
-    { "device", 0 },  // filled by code
-    { 0, 0 },
+  struct label labels[] = {
+    { .key = "device", .value = 0 },  // value filled by code
+    LABEL_END,
   };
 
   char buf[BUF_SIZE];
@@ -123,7 +123,7 @@ static void diskstats_collect(scrape_req *req, void *ctx_ptr) {
     char *dev = strtok_r(0, " ", &p);
     if (!dev || *dev == '\0')
       continue;
-    labels[0][1] = dev;
+    labels[0].value = dev;
 
     // filter