From 31d166be00f9ea08cda1facf6ac275da3e7262ac Mon Sep 17 00:00:00 2001 From: ManuelBahr Date: Thu, 20 Jul 2017 10:42:53 +0200 Subject: [PATCH 1/2] fix for #12 --- azure_costs_exporter/prometheus_collector.py | 2 +- tests/data.py | 4 ++-- tests/test_collector.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/azure_costs_exporter/prometheus_collector.py b/azure_costs_exporter/prometheus_collector.py index fae34b2..618ddba 100644 --- a/azure_costs_exporter/prometheus_collector.py +++ b/azure_costs_exporter/prometheus_collector.py @@ -104,6 +104,6 @@ def collect(self): groups = df.groupby(base_columns).sum() for name, value in groups.iterrows(): - c.add_metric(name, value.ExtendedCost) + c.add_metric(name, int(round(value.ExtendedCost))) yield c \ No newline at end of file diff --git a/tests/data.py b/tests/data.py index 113de08..c3b8ec1 100644 --- a/tests/data.py +++ b/tests/data.py @@ -11,7 +11,7 @@ u'Date': u'03/01/2017', u'Day': 1, u'DepartmentName': u'Engineering', - u'ExtendedCost': 0.71, + u'ExtendedCost': 0.499222332425423563466, u'InstanceId': u'platform-vnet', u'MeterCategory': u'Virtual Network', u'MeterId': u'c90286c8-adf0-438e-a257-4468387df385', @@ -42,7 +42,7 @@ u'Date': u'03/01/2017', u'Day': 1, u'DepartmentName': u'Engineering', - u'ExtendedCost': 0.24, + u'ExtendedCost': 0.50000011123124314235234522345, u'InstanceId': u'/subscriptions/abc3455ac-3feg-2b3c5-abe4-ec1111111e6/resourceGroups/my-group/providers/Microsoft.Storage/storageAccounts/ss7q3264domxo', u'MeterCategory': u'Windows Azure Storage', u'MeterId': u'd23a5753-ff85-4ddf-af28-8cc5cf2d3882', diff --git a/tests/test_collector.py b/tests/test_collector.py index 0309313..1bf4775 100644 --- a/tests/test_collector.py +++ b/tests/test_collector.py @@ -49,8 +49,8 @@ def test_extract_metrics(): result = generate_latest(registry).decode('utf8').split('\n') assert len(result) == 5 - expected_0 = 'costs{AccountName="platform",DepartmentName="engineering",MeterCategory="virtual network",MeterName="hours",MeterSubCategory="gateway hour",ResourceGroup="",SubscriptionName="production"} 0.71' - expected_1 = 'costs{AccountName="platform",DepartmentName="engineering",MeterCategory="windows azure storage",MeterName="standard io - page blob/disk (gb)",MeterSubCategory="locally redundant",ResourceGroup="my-group",SubscriptionName="production"} 0.24' + expected_0 = 'costs{AccountName="platform",DepartmentName="engineering",MeterCategory="virtual network",MeterName="hours",MeterSubCategory="gateway hour",ResourceGroup="",SubscriptionName="production"} 0.0' + expected_1 = 'costs{AccountName="platform",DepartmentName="engineering",MeterCategory="windows azure storage",MeterName="standard io - page blob/disk (gb)",MeterSubCategory="locally redundant",ResourceGroup="my-group",SubscriptionName="production"} 1.0' assert result[2] == expected_0 assert result[3] == expected_1 From 07ce7ed30b915af451121884c49a469bd37fc308 Mon Sep 17 00:00:00 2001 From: ManuelBahr Date: Thu, 20 Jul 2017 10:43:02 +0200 Subject: [PATCH 2/2] adapted changelog for the release --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76dc425..dbdbc60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ Change Log All notable changes to this project are noted in this file. This project adheres to [Semantic Versioning](http://semver.org/). +0.3.2 +----- + +- Fixed issue (https://github.com/blue-yonder/azure-cost-mon/issues/12) + where the sum of multiple time series was numerically instable by + emitting only integer values. The instability resulted in more counter + resets within Prometheus than necessary, so that `increase` gave wrong + results! + 0.3.1 -----