Fix and document counter types
Document each counter type available and fixes the various counter already implemented. This fixes bug #1023969. Change-Id: Ibc8b726d59c3f9433109096958b1d40db043e70d Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
6b9bd89649
commit
dcce2c7323
@ -120,7 +120,7 @@ class CPUPollster(plugin.PollsterBase):
|
||||
)
|
||||
yield make_counter_from_instance(instance,
|
||||
name='instance',
|
||||
type='delta',
|
||||
type='cumulative',
|
||||
volume=1,
|
||||
)
|
||||
except Exception as err:
|
||||
|
@ -39,7 +39,7 @@ class FloatingIPPollster(plugin.PollsterBase):
|
||||
yield counter.Counter(
|
||||
source='?',
|
||||
name='floating_ip',
|
||||
type='delta',
|
||||
type='cumulative',
|
||||
volume=1,
|
||||
user_id=None,
|
||||
project_id=ip.project_id,
|
||||
|
@ -39,7 +39,7 @@ class InstanceNotifications(plugin.NotificationBase):
|
||||
return [counter.Counter(
|
||||
source='?',
|
||||
name='instance',
|
||||
type='delta',
|
||||
type='cumulative',
|
||||
volume=1,
|
||||
user_id=message['payload']['user_id'],
|
||||
project_id=message['payload']['tenant_id'],
|
||||
|
@ -24,7 +24,22 @@ in by the plugins that create them.
|
||||
|
||||
import collections
|
||||
|
||||
|
||||
# Fields explanation:
|
||||
#
|
||||
# Source:
|
||||
# Name: the name of the counter, must be unique
|
||||
# Type: the type of the counter, must be either:
|
||||
# - cumulative: the value is incremented and never reset to 0
|
||||
# - delta: the value is reset to 0 each time it is sent
|
||||
# - absolute: the value is an absolute value and is not a counter
|
||||
# Volume: the counter value
|
||||
# User ID: the user ID
|
||||
# Project ID: the project ID
|
||||
# Resource ID: the resource ID
|
||||
# Timestamp: when the counter has been read
|
||||
# Duration: duration in seconds determining how long the value is valid.
|
||||
# adding this to timestamp give the end time of the counter
|
||||
# Resource metadata: various metadata
|
||||
Counter = collections.namedtuple('Counter',
|
||||
' '.join(['source',
|
||||
'name',
|
||||
|
@ -64,7 +64,7 @@ from libvirt and send back two ``Counter`` objects. The first one, named
|
||||
"cpu", is of type "cumulative", meaning that between two polls, its value is
|
||||
not reset, or in other word that the cpu value is always provided as a duration
|
||||
that continuously increases since the creation of the instance. The second one,
|
||||
named "instance", is of type "delta", meaning that it's value is just the
|
||||
named "instance", is of type "cumulative", meaning that it's value is just the
|
||||
volume since the last poll. Here, the instance counter is only used as a way
|
||||
to tell the system that the instance is still running, hence the hard coded
|
||||
value of 1.
|
||||
|
@ -172,7 +172,7 @@ def test_process_notification():
|
||||
|
||||
for name, actual, expected in [
|
||||
('counter_name', info.name, 'instance'),
|
||||
('counter_type', info.type, 'delta'),
|
||||
('counter_type', info.type, 'cumulative'),
|
||||
('counter_volume', info.volume, 1),
|
||||
('timestamp', info.timestamp,
|
||||
INSTANCE_CREATE_END['timestamp']),
|
||||
|
Loading…
x
Reference in New Issue
Block a user