"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cloudkitty/collector/prometheus.py" between
cloudkitty-16.0.0.tar.gz and cloudkitty-17.0.0.tar.gz

About: OpenStack CloudKitty provides Rating-as-a-Service for OpenStack.
The "Zed" series (latest release).

prometheus.py  (cloudkitty-16.0.0):prometheus.py  (cloudkitty-17.0.0)
skipping to change at line 149 skipping to change at line 149
with localcontext() as ctx: with localcontext() as ctx:
ctx.prec = 9 ctx.prec = 9
ctx.rounding = ROUND_HALF_UP ctx.rounding = ROUND_HALF_UP
qty = ck_utils.convert_unit( qty = ck_utils.convert_unit(
+Decimal(data['value'][1]), +Decimal(data['value'][1]),
self.conf[metric_name]['factor'], self.conf[metric_name]['factor'],
self.conf[metric_name]['offset'], self.conf[metric_name]['offset'],
) )
qty = ck_utils.mutate(qty, self.conf[metric_name]['mutate']) mutate_map = self.conf[metric_name].get('mutate_map')
qty = ck_utils.mutate(qty, self.conf[metric_name]['mutate'],
mutate_map=mutate_map)
return metadata, groupby, qty return metadata, groupby, qty
def fetch_all(self, metric_name, start, end, scope_id, q_filter=None): def fetch_all(self, metric_name, start, end, scope_id, q_filter=None):
"""Returns metrics to be valorized.""" """Returns metrics to be valorized."""
scope_key = CONF.collect.scope_key scope_key = CONF.collect.scope_key
method = self.conf[metric_name]['extra_args']['aggregation_method'] method = self.conf[metric_name]['extra_args']['aggregation_method']
query_function = self.conf[metric_name]['extra_args'].get( query_function = self.conf[metric_name]['extra_args'].get(
'query_function') 'query_function')
range_function = self.conf[metric_name]['extra_args'].get( range_function = self.conf[metric_name]['extra_args'].get(
skipping to change at line 220 skipping to change at line 222
query = "{0} {1}".format(query, query_suffix) query = "{0} {1}".format(query, query_suffix)
try: try:
res = self._conn.get_instant( res = self._conn.get_instant(
query, query,
time.isoformat(), time.isoformat(),
) )
except PrometheusResponseError as e: except PrometheusResponseError as e:
raise CollectError(*e.args) raise CollectError(*e.args)
if res['status'] == 'error':
error_type = res['errorType']
error_msg = res['error']
raise CollectError("%s: %s" % (error_type, error_msg))
# If the query returns an empty dataset, # If the query returns an empty dataset,
# return an empty list # return an empty list
if not res['data']['result']: if not res['data']['result']:
return [] return []
formatted_resources = [] formatted_resources = []
for item in res['data']['result']: for item in res['data']['result']:
metadata, groupby, qty = self._format_data( metadata, groupby, qty = self._format_data(
metric_name, metric_name,
 End of changes. 2 change blocks. 
1 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)