diff options
author | Heikki Kallasjoki <fis@zem.fi> | 2018-12-07 02:12:32 +0000 |
---|---|---|
committer | Heikki Kallasjoki <fis+github@zem.fi> | 2018-12-07 02:17:55 +0000 |
commit | 7ec8aa9fcfba92019f537cd19dac4ce15674ddd6 (patch) | |
tree | edfdfcb09dd20e54f9cd4742346c1bf8a45e60d2 /scrape.c | |
parent | 16d61af28bcd07348117fd457b62ff39c1a0b45d (diff) | |
download | nano-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 'scrape.c')
-rw-r--r-- | scrape.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/scrape.c b/scrape.c index 463efc1..f9c711b 100644 --- a/scrape.c +++ b/scrape.c @@ -150,17 +150,17 @@ void scrape_close(scrape_server *srv) { free(srv); } -void scrape_write(scrape_req *req, const char *metric, const char *(*labels)[2], double value) { +void scrape_write(scrape_req *req, const char *metric, const struct label *labels, double value) { cbuf_reset(req->buf); cbuf_puts(req->buf, metric); - if (labels && (*labels)[0]) { + if (labels && labels->key) { cbuf_putc(req->buf, '{'); - for (const char *(*l)[2] = labels; (*l)[0]; l++) { + for (const struct label *l = labels; l->key; l++) { if (l != labels) cbuf_putc(req->buf, ','); - cbuf_putf(req->buf, "%s=\"%s\"", (*l)[0], (*l)[1]); + cbuf_putf(req->buf, "%s=\"%s\"", l->key, l->value); } cbuf_putc(req->buf, '}'); } |