From 470835030ebe2d4a1e3082d2139bd1e860f707c6 Mon Sep 17 00:00:00 2001 From: George Hickman Date: Thu, 2 Nov 2023 16:12:34 +0000 Subject: [PATCH] Allow tags to be empty when writing to influx --- metrics/influxdb.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/metrics/influxdb.py b/metrics/influxdb.py index 23d3c70c..ce4b34d5 100644 --- a/metrics/influxdb.py +++ b/metrics/influxdb.py @@ -36,6 +36,9 @@ def delete(key): def write(measurement, date, value, tags=None): + if tags is None: + tags = {} + # convert date to a timestamp # TODO: do we need to do any checking to make sure this is tz-aware and in # UTC? @@ -43,9 +46,8 @@ def write(measurement, date, value, tags=None): point = Point(measurement).field("number", value).time(dt) - if tags is not None: - for k, v in tags.items(): - point = point.tag(k, v) + for k, v in tags.items(): + point = point.tag(k, v) write_api.write(bucket=BUCKET, org=ORG, record=point)