ceilometer.event.trait_plugins
Module¶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.
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.
support_return_all_values
= True¶ceilometer.event.trait_plugins.
TimedeltaPlugin
(**kw)[source]¶Bases: ceilometer.event.trait_plugins.TraitPluginBase
Setup timedelta meter volume of two timestamps fields.
Example:
trait's fields definition: ['payload.created_at',
'payload.launched_at']
value is been created as total seconds between 'launched_at' and
'created_at' timestamps.
ceilometer.event.trait_plugins.
TimedeltaPluginMissedFields
[source]¶Bases: exceptions.Exception
ceilometer.event.trait_plugins.
TraitPluginBase
(**kw)[source]¶Bases: object
Base class for plugins.
It converts notification fields to Trait values.
support_return_all_values
= False¶If True, an exception will be raised if the user expect the plugin to return one trait per match_list, but the plugin doesn’t allow/support that.
trait_values
(match_list)[source]¶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. |
---|
Example:
trait's fields definition: ['payload.foobar',
'payload.baz',
'payload.thing.*']
notification body:
{
'metadata': {'message_id': '12345'},
'publisher': 'someservice.host',
'payload': {
'foobar': 'test',
'thing': {
'bar': 12,
'boing': 13,
}
}
}
match_list will be: [('payload.foobar','test'),
('payload.thing.bar',12),
('payload.thing.boing',13)]
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]
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.