about summary refs log tree commit diff
path: root/network.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 /network.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 'network.c')
-rw-r--r--network.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/network.c b/network.c
index 5eb2715..7b0e548 100644
--- a/network.c
+++ b/network.c
@@ -149,9 +149,9 @@ static void network_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];
@@ -176,7 +176,7 @@ static void network_collect(scrape_req *req, void *ctx_ptr) {
     if (!p)
       continue;
     *p = '\0';
-    labels[0][1] = dev;
+    labels[0].value = dev;
     p++;
 
     if (ctx->include) {