The ceilometer.event.trait_plugins Module

class ceilometer.event.trait_plugins.BitfieldTraitPlugin(initial_bitfield=0, flags=None, **kw)[source]

Bases: ceilometer.event.trait_plugins.TraitPluginBase

Plugin to set flags on a bitfield.

class ceilometer.event.trait_plugins.SplitterTraitPlugin(separator='.', segment=0, max_split=None, **kw)[source]

Bases: ceilometer.event.trait_plugins.TraitPluginBase

Plugin that splits a piece off of a string value.

class ceilometer.event.trait_plugins.TimedeltaPlugin(**kw)[source]

Bases: ceilometer.event.trait_plugins.TraitPluginBase

Setup timedelta meter volume of two timestamps fields.


trait's fields definition: ['payload.created_at',
value is been created as total seconds between 'launched_at' and
'created_at' timestamps.
exception ceilometer.event.trait_plugins.TimedeltaPluginMissedFields[source]

Bases: exceptions.Exception

class ceilometer.event.trait_plugins.TraitPluginBase(**kw)[source]

Bases: object

Base class for plugins.

It converts notification fields to Trait values.


Convert a set of fields to one or multiple Trait values.

This method is called each time a trait is attempted to be extracted from a notification. It will be called even if no matching fields are found in the notification (in that case, the match_list will be empty). If this method returns None, the trait will not be added to the event. Any other value returned by this method will be used as the value for the trait. Values returned will be coerced to the appropriate type for the trait.

Parameters:match_list – A list (may be empty if no matches) of tuples. Each tuple is (field_path, value) where field_path is the jsonpath for that specific field.


trait's fields definition: ['payload.foobar',
notification body:
             'message_id': '12345',
             'publisher': '',
             'payload': {
                         'foobar': 'test',
                         'thing': {
                                   'bar': 12,
                                   'boing': 13,
match_list will be: [('payload.foobar','test'),

Here is a plugin that emulates the default (no plugin) behavior:

class DefaultPlugin(TraitPluginBase):
    "Plugin that returns the first field value."

    def __init__(self, **kw):
        super(DefaultPlugin, self).__init__()

    def trait_value(self, match_list):
        if not match_list:
            return None
        return [ match[1] for match in match_list]

Previous topic

The Module

Next topic

The ceilometer.exchange_control Module

Project Source

This Page