snap_plugin.v1.namespace module

class snap_plugin.v1.namespace.Namespace(pb, *elements)

Bases: object

Namespace of a metric.

:param elements (list of: NamespaceElement
or list of strings): namespace elements
add(namespace_element)
add_dynamic_element(name, description)

Adds a dynamic namespace element to the end of the Namespace.

A dynamic namespace element is defined by an element that contains a non-static data relative to the metric being collected. For instance, when collecting metrics for a given virtual machine the namespace element that contains the virtual-machine-id would be dynamic. This is modeled by the a NamespaceElement when its name attribute contains the value ‘virtual-machine-id’. In this example the value attribute would be set to the ID of the virtual machine when the metric is collected.

Parameters:value (snap_plugin.v1.namespace_element.NamespaceElement) – namespace element
Returns:snap_plugin.v1.namespace.Namespace
add_static_element(value)

Adds a static namespace element to the end of the Namespace.

A static namespace element is defined by the value attribute being set and where the name attribute is not used (set to None). This is the case when the namespace does not change based on what is being collected.

Parameters:value (snap_plugin.v1.namespace_element.NamespaceElement) – namespace element
Returns:snap_plugin.v1.namespace.Namespace
pop(key=-1)

Removes and retuns the namespace element at a given index.

If the kwarg ‘key’ is provided the item at the given index is removed and returned. If the kwarg ‘key’’ is not provided the last Namespace element is removed and returned.

Parameters:**kwargs (optional) – key=-1