snap_plugin.v1.collector module

class snap_plugin.v1.collector.Collector(name, version, **kwargs)

Bases: snap_plugin.v1.plugin.Plugin

Abstract base class for ‘collector’ plugins.

This class makes the creation of a snap ‘collector’ plugin as easy as possible. For instance, when a class inherits from py:class:snap_plugin.v1.collector.Collector plugins can be created by providing implementations for:

collect(metrics)

Collect requested metrics.

This method is abstract so the implementation must be provided by the plugin which extends snap_plugin.v1.Collector.

This method is called by the Snap deamon during the collection phase of the execution of a Snap workflow.

Parameters:metrics (list of snap_plugin.v1.Metric) – List of metrics to be collected.
Returns:List of collected metrics.
Return type:list of snap_plugin.v1.Metric
update_catalog(config)

Returns the metrics which the plugin provides.

This method is called by the Snap daemon when the plugin is loaded and returns a list of snap_plugin.v1.metric.Metric that will populate the snap metric catalog. The method is abstract so the implementation must be provided by the plugin which extends snap_plugin.v1.Collector.

Note: Requiring config to successfully return metric types should be avoided. Only in rare circumstances should a plugin require configuration data for it to load.

Parameters:config (snap_plugin.v1.ConfigMap) – Provides configuration data.
Returns:List of collectable metrics.
Return type:list of snap_plugin.v1.Metric