Skip to content
This repository has been archived by the owner on May 19, 2021. It is now read-only.

fixes for #12 - Float num instability #13

Merged
merged 3 commits into from
Jul 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,30 @@ Change Log
All notable changes to this project are noted in this file. This project adheres to [Semantic
Versioning](http://semver.org/).

0.4.1
-----

- 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.4.0
-----

- Use the `X-Prometheus-Scrape-Timeout-Seconds` header sent by
prometheus to overwrite the internal request timeout default.


0.3.1
-----

- Fixed the exporter to cope with the non-standard response for months
without usage details.


0.3.0
-----

Expand Down
2 changes: 1 addition & 1 deletion azure_costs_exporter/prometheus_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,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
4 changes: 2 additions & 2 deletions tests/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def test_extract_metrics(api_url, enrollment):
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
Expand Down