Skip to content

Commit

Permalink
new(plugin_api): add plugin metrics symbols and types
Browse files Browse the repository at this point in the history
Signed-off-by: Gianmatteo Palmieri <[email protected]>
  • Loading branch information
mrgian authored and poiana committed May 16, 2024
1 parent 4c993d6 commit 8a860c1
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
11 changes: 11 additions & 0 deletions userspace/plugin/plugin_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,17 @@ typedef struct
// or SS_PLUGIN_FAILURE if the config is rejected.
// If rejected the plugin should provide context in the string returned by get_last_error().
ss_plugin_rc (*set_config)(ss_plugin_t* s, const ss_plugin_set_config_input* i);

//
// Return an updated set of metrics provided by this plugin.
// Required: no
// - s: the plugin state, returned by init(). Can be NULL.
// - num_metrics: lenght of the returned metrics array.
//
// Return value: Pointer to the first element of the metrics array.
// 'num_metrics' must be set to the lenght of the array before returning
// and it can be set to 0 if no metrics are provided.
ss_plugin_metric* (*get_metrics)(ss_plugin_t* s, uint32_t* num_metrics);
} plugin_api;

#ifdef __cplusplus
Expand Down
49 changes: 49 additions & 0 deletions userspace/plugin/plugin_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,55 @@ typedef enum ss_plugin_log_severity
SS_PLUGIN_LOG_SEV_TRACE = 8,
} ss_plugin_log_severity;

// Types supported by the by the metric values
typedef enum ss_plugin_metric_value_type
{
SS_PLUGIN_METRIC_VALUE_TYPE_U32 = 1,
SS_PLUGIN_METRIC_VALUE_TYPE_S32 = 2,
SS_PLUGIN_METRIC_VALUE_TYPE_U64 = 3,
SS_PLUGIN_METRIC_VALUE_TYPE_S64 = 4,
SS_PLUGIN_METRIC_VALUE_TYPE_D = 5,
SS_PLUGIN_METRIC_VALUE_TYPE_F = 6,
SS_PLUGIN_METRIC_VALUE_TYPE_I = 7,
} ss_plugin_metric_value_type;

// Data representation of metric values
typedef union ss_plugin_metric_value
{
uint32_t u32;
int32_t s32;
uint64_t u64;
int64_t s64;
double d;
float f;
int i;
} ss_plugin_metric_value;

// Metric types
typedef enum ss_plugin_metric_type
{
SS_PLUGIN_METRIC_TYPE_MONOTONIC = 1,
SS_PLUGIN_METRIC_TYPE_NON_MONOTONIC = 2,
} ss_plugin_metric_type;

//
// Struct representing a metric to be provided to the plugin framework
typedef struct ss_plugin_metric
{
//
// Opaque string representing the metric name
const char* name;
//
// Metric type
ss_plugin_metric_type type;
//
// Metric numeric value
ss_plugin_metric_value value;
//
// Metric value data type
ss_plugin_metric_value_type value_type;
} ss_plugin_metric;

#ifdef __cplusplus
}
#endif

0 comments on commit 8a860c1

Please sign in to comment.