Skip to content

Commit

Permalink
Rounding fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
niemijoe committed Aug 19, 2022
1 parent b0f7aa2 commit 0d5e81e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion mqtt_data_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,13 @@ def get_series_array(topic_data_collection):
for key in topic_data_collection:
topic_msg_count = topic_data_collection[key]

# We want message count to be message per second
# We want message count to be messages per second
topic_msg_count = round(topic_msg_count/MONITOR_PERIOD_IN_SECONDS, 2)

# If over 10, round to whole number
if topic_msg_count > 10:
topic_msg_count = round(topic_msg_count)

# Azure doesn't seem to like # in a dimValue, replace it with *
parsed_key = key.replace("#", "*")
# Azure doesn't seem to like + in a dimValue, replace it with ^
Expand Down
12 changes: 7 additions & 5 deletions pulsar_data_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,18 @@ def get_series_array(topic_data_collection, topic_data_metric_name, topic_names_
series_array = []
for topic_name in topic_names_to_collect:
topic_msg_count = topic_data_collection[topic_name][topic_data_metric_name]
# Special case: we want to multiply stop-cancellation messages by 10
# so that the data would show more likely in Azure's charts
if topic_name == "internal-messages/stop-cancellation":
topic_msg_count = topic_msg_count * 10

topic_msg_count = round(topic_msg_count, 2)

# If over 10, round to whole number
if topic_msg_count > 10:
topic_msg_count = round(topic_msg_count)

dimValue = {
"dimValues": [
topic_name
],
"sum": round(topic_msg_count),
"sum": topic_msg_count,
"count": 1
}
series_array.append(dimValue)
Expand Down

0 comments on commit 0d5e81e

Please sign in to comment.