Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Metrics must be sent even when tag is None #487

Merged
merged 1 commit into from
Aug 28, 2023
Merged

Conversation

eliska-n
Copy link
Collaborator

or - maybe "cleaner" solution:

return {k.replace(" ", "\\ ").replace(",", "\\,").replace("=", "\\="): str(v).replace(" ", "\\ ").replace(",", "\\,").replace("=", "\\=") for k,  v in tags.items()}

In this case, the None tag would be "None". Which is still better than nothing and comprehensions are faster.

Original bug:

25-Aug-2023 09:01:34.107737 ERROR root Task exception was never retrieved
{'future': <Task finished coro=<InfluxDBTarget.process() done, defined at /usr/local/lib/python3.7/site-packages/asab/metrics/influxdb.py:104> exception=AttributeError("'NoneType' object has no attribute 'replace'")>}
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/asab/metrics/influxdb.py", line 105, in process
    rb = influxdb_format(m_tree, now)
  File "/usr/local/lib/python3.7/site-packages/asab/metrics/influxdb.py", line 243, in influxdb_format
    influx_records = metric_to_influxdb(metric_record, now)
  File "/usr/local/lib/python3.7/site-packages/asab/metrics/influxdb.py", line 206, in metric_to_influxdb
    values_lines.append(build_metric_line(field.get("tags"), (field.get("values")), timestamp))
  File "/usr/local/lib/python3.7/site-packages/asab/metrics/influxdb.py", line 169, in build_metric_line
    return combine_tags_and_field(tags, values, timestamp)
  File "/usr/local/lib/python3.7/site-packages/asab/metrics/influxdb.py", line 158, in combine_tags_and_field
    tags = escape_tags(tags)
  File "/usr/local/lib/python3.7/site-packages/asab/metrics/influxdb.py", line 223, in escape_tags
    clean[k.replace(" ", "\\ ").replace(",", "\\,").replace("=", "\\=")] = v.replace(" ", "\\ ").replace(",", "\\,").replace("=", "\\=")
AttributeError: 'NoneType' object has no attribute 'replace'

@ateska ateska added the bug Something isn't working label Aug 25, 2023
@eliska-n eliska-n merged commit 4fed659 into master Aug 28, 2023
10 checks passed
@eliska-n eliska-n deleted the fix/metrics-influx branch August 28, 2023 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants