diff options
author | Julien Danjou <julien@danjou.info> | 2013-06-14 13:51:39 +0200 |
---|---|---|
committer | Julien Danjou <julien@danjou.info> | 2013-07-05 13:40:25 +0200 |
commit | 00531f9de040f43c643dd843ada986cfbcf91e87 (patch) | |
tree | 9c56ff06840f8d349c8d8a5bd70cc91d8f255ca9 /ceilometer/image | |
parent | bd594cbde1cc3f4d640f0d606a0c4830c26da1ef (diff) | |
download | ceilometer-00531f9de040f43c643dd843ada986cfbcf91e87.tar.gz |
Unify Counter generation from notifications
This will make sure we don't lose any metadata information from
notifications into the Counter/samples we publish.
This is part of fixing bug #1187833 and bug #1187843
Change-Id: I315581907be1dcec33f43a5d5fd7b7876a7889f6
Signed-off-by: Julien Danjou <julien@danjou.info>
Diffstat (limited to 'ceilometer/image')
-rw-r--r-- | ceilometer/image/notifications.py | 144 |
1 files changed, 45 insertions, 99 deletions
diff --git a/ceilometer/image/notifications.py b/ceilometer/image/notifications.py index cfee9aab..a601bd27 100644 --- a/ceilometer/image/notifications.py +++ b/ceilometer/image/notifications.py @@ -51,25 +51,6 @@ class ImageBase(plugin.NotificationBase): class ImageCRUDBase(ImageBase): - - metadata_keys = [ - 'name', - 'size', - 'status', - 'disk_format', - 'container_format', - 'location', - 'deleted', - 'created_at', - 'updated_at', - 'properties', - 'protected', - 'checksum', - 'is_public', - 'deleted_at', - 'min_ram', - ] - @staticmethod def get_event_types(): return [ @@ -80,67 +61,46 @@ class ImageCRUDBase(ImageBase): class ImageCRUD(ImageCRUDBase): - def process_notification(self, message): - metadata = self.notification_to_metadata(message) - return [ - counter.Counter( - name=message['event_type'], - type=counter.TYPE_DELTA, - unit='image', - volume=1, - resource_id=message['payload']['id'], - user_id=None, - project_id=message['payload']['owner'], - timestamp=message['timestamp'], - resource_metadata=metadata, - ), - ] + yield counter.Counter.from_notification( + name=message['event_type'], + type=counter.TYPE_DELTA, + unit='image', + volume=1, + resource_id=message['payload']['id'], + user_id=None, + project_id=message['payload']['owner'], + message=message) class Image(ImageCRUDBase): - def process_notification(self, message): - metadata = self.notification_to_metadata(message) - return [ - counter.Counter( - name='image', - type=counter.TYPE_GAUGE, - unit='image', - volume=1, - resource_id=message['payload']['id'], - user_id=None, - project_id=message['payload']['owner'], - timestamp=message['timestamp'], - resource_metadata=metadata, - ), - ] + yield counter.Counter.from_notification( + name='image', + type=counter.TYPE_GAUGE, + unit='image', + volume=1, + resource_id=message['payload']['id'], + user_id=None, + project_id=message['payload']['owner'], + message=message) class ImageSize(ImageCRUDBase): - def process_notification(self, message): - metadata = self.notification_to_metadata(message) - return [ - counter.Counter( - name='image.size', - type=counter.TYPE_GAUGE, - unit='B', - volume=message['payload']['size'], - resource_id=message['payload']['id'], - user_id=None, - project_id=message['payload']['owner'], - timestamp=message['timestamp'], - resource_metadata=metadata, - ), - ] + yield counter.Counter.from_notification( + name='image.size', + type=counter.TYPE_GAUGE, + unit='B', + volume=message['payload']['size'], + resource_id=message['payload']['id'], + user_id=None, + project_id=message['payload']['owner'], + message=message) class ImageDownload(ImageBase): """Emit image_download counter when an image is downloaded.""" - - metadata_keys = ['destination_ip', 'owner_id'] - @staticmethod def get_event_types(): return [ @@ -148,28 +108,19 @@ class ImageDownload(ImageBase): ] def process_notification(self, message): - metadata = self.notification_to_metadata(message) - return [ - counter.Counter( - name='image.download', - type=counter.TYPE_DELTA, - unit='B', - volume=message['payload']['bytes_sent'], - resource_id=message['payload']['image_id'], - user_id=message['payload']['receiver_user_id'], - project_id=message['payload']['receiver_tenant_id'], - timestamp=message['timestamp'], - resource_metadata=metadata, - ), - ] + yield counter.Counter.from_notification( + name='image.download', + type=counter.TYPE_DELTA, + unit='B', + volume=message['payload']['bytes_sent'], + resource_id=message['payload']['image_id'], + user_id=message['payload']['receiver_user_id'], + project_id=message['payload']['receiver_tenant_id'], + message=message) class ImageServe(ImageBase): """Emit image_serve counter when an image is served out.""" - - metadata_keys = ['destination_ip', 'receiver_user_id', - 'receiver_tenant_id'] - @staticmethod def get_event_types(): return [ @@ -177,17 +128,12 @@ class ImageServe(ImageBase): ] def process_notification(self, message): - metadata = self.notification_to_metadata(message) - return [ - counter.Counter( - name='image.serve', - type=counter.TYPE_DELTA, - unit='B', - volume=message['payload']['bytes_sent'], - resource_id=message['payload']['image_id'], - user_id=None, - project_id=message['payload']['owner_id'], - timestamp=message['timestamp'], - resource_metadata=metadata, - ), - ] + yield counter.Counter.from_notification( + name='image.serve', + type=counter.TYPE_DELTA, + unit='B', + volume=message['payload']['bytes_sent'], + resource_id=message['payload']['image_id'], + user_id=None, + project_id=message['payload']['owner_id'], + message=message) |