Skip to content

Commit

Permalink
Allow tags to be empty when writing to influx
Browse files Browse the repository at this point in the history
  • Loading branch information
ghickman committed Nov 2, 2023
1 parent bd4d8f1 commit 4708350
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions metrics/influxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ 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?
dt = datetime.combine(date, time())

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)

Expand Down

0 comments on commit 4708350

Please sign in to comment.