Flecs v4.0
A fast entity component system (ECS) for C & C++
|
Create alerts from monitoring queries. More...
Classes | |
struct | EcsAlertInstance |
Component added to alert instance. More... | |
struct | EcsAlertsActive |
Map with active alerts for entity. More... | |
struct | ecs_alert_severity_filter_t |
Alert severity filter. More... | |
struct | ecs_alert_desc_t |
Alert descriptor, used with ecs_alert_init(). More... | |
Macros | |
#define | ECS_ALERT_MAX_SEVERITY_FILTERS (4) |
#define | ecs_alert(world, ...) ecs_alert_init(world, &(ecs_alert_desc_t)__VA_ARGS__) |
Create a new alert. | |
Typedefs | |
typedef struct EcsAlertInstance | EcsAlertInstance |
Component added to alert instance. | |
typedef struct EcsAlertsActive | EcsAlertsActive |
Map with active alerts for entity. | |
typedef struct ecs_alert_severity_filter_t | ecs_alert_severity_filter_t |
Alert severity filter. | |
typedef struct ecs_alert_desc_t | ecs_alert_desc_t |
Alert descriptor, used with ecs_alert_init(). | |
Functions | |
FLECS_API | ECS_COMPONENT_DECLARE (FlecsAlerts) |
Module id. | |
FLECS_API | ECS_COMPONENT_DECLARE (EcsAlert) |
Component added to alert, and used as first element of alert severity pair. | |
FLECS_API | ECS_COMPONENT_DECLARE (EcsAlertInstance) |
Component added to alert instance. | |
FLECS_API | ECS_COMPONENT_DECLARE (EcsAlertsActive) |
Component added to alert source which tracks how many active alerts there are. | |
FLECS_API | ECS_COMPONENT_DECLARE (EcsAlertTimeout) |
Component added to alert which tracks how long an alert has been inactive. | |
FLECS_API | ECS_TAG_DECLARE (EcsAlertInfo) |
Info alert severity. | |
FLECS_API | ECS_TAG_DECLARE (EcsAlertWarning) |
Warning alert severity. | |
FLECS_API | ECS_TAG_DECLARE (EcsAlertError) |
Error alert severity. | |
FLECS_API | ECS_TAG_DECLARE (EcsAlertCritical) |
Critical alert severity. | |
FLECS_API ecs_entity_t | ecs_alert_init (ecs_world_t *world, const ecs_alert_desc_t *desc) |
Create a new alert. | |
FLECS_API int32_t | ecs_get_alert_count (const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t alert) |
Return number of active alerts for entity. | |
FLECS_API ecs_entity_t | ecs_get_alert (const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t alert) |
Return alert instance for specified alert. | |
FLECS_API void | FlecsAlertsImport (ecs_world_t *world) |
Alert module import function. | |
Create alerts from monitoring queries.
#define ecs_alert | ( | world, | |
... ) ecs_alert_init(world, &(ecs_alert_desc_t)__VA_ARGS__) |
typedef struct ecs_alert_severity_filter_t ecs_alert_severity_filter_t |
Alert severity filter.
A severity filter can adjust the severity of an alert based on whether an entity in the alert query has a specific component. For example, a filter could check if an entity has the "Production" tag, and increase the default severity of an alert from Warning to Error.
FLECS_API ecs_entity_t ecs_alert_init | ( | ecs_world_t * | world, |
const ecs_alert_desc_t * | desc ) |
Create a new alert.
An alert is a query that is evaluated periodically and creates alert instances for each entity that matches the query. Alerts can be used to automate detection of errors in an application.
Alerts are automatically cleared when a query is no longer true for an alert instance. At most one alert instance will be created per matched entity.
Alert instances have three components:
Alerts reuse components from the metrics addon so that alert instances can be tracked and discovered as metrics. Just like metrics, alert instances are created as children of the alert.
When an entity has active alerts, it will have the EcsAlertsActive component which contains a map with active alerts for the entity. This component will be automatically removed once all alerts are cleared for the entity.
world | The world. |
desc | Alert description. |
FLECS_API ecs_entity_t ecs_get_alert | ( | const ecs_world_t * | world, |
ecs_entity_t | entity, | ||
ecs_entity_t | alert ) |
Return alert instance for specified alert.
This operation returns the alert instance for the specified alert. If the alert is not active for the entity, the operation will return 0.
world | The world. |
entity | The entity. |
alert | The alert to test for. |
FLECS_API int32_t ecs_get_alert_count | ( | const ecs_world_t * | world, |
ecs_entity_t | entity, | ||
ecs_entity_t | alert ) |
Return number of active alerts for entity.
When a valid alert entity is specified for the alert parameter, the operation will return whether the specified alert is active for the entity. When no alert is specified, the operation will return the total number of active alerts for the entity.
world | The world. |
entity | The entity. |
alert | The alert to test for (optional). |
FLECS_API void FlecsAlertsImport | ( | ecs_world_t * | world | ) |