Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
Alerts

Create alerts from monitoring queries. More...

Collaboration diagram for Alerts:

Classes

struct  EcsAlertInstance
 Alert information. More...
 
struct  EcsAlertsActive
 Map with active alerts for entity. More...
 
struct  ecs_alert_severity_filter_t
 
struct  ecs_alert_desc_t
 

Macros

#define ECS_ALERT_MAX_SEVERITY_FILTERS   (4)
 
#define ecs_alert(world, ...)    ecs_alert_init(world, &(ecs_alert_desc_t)__VA_ARGS__)
 

Typedefs

typedef struct EcsAlertInstance EcsAlertInstance
 Alert information.
 
typedef struct EcsAlertsActive EcsAlertsActive
 Map with active alerts for entity.
 
typedef struct ecs_alert_severity_filter_t ecs_alert_severity_filter_t
 
typedef struct ecs_alert_desc_t ecs_alert_desc_t
 

Functions

FLECS_API ECS_COMPONENT_DECLARE (FlecsAlerts)
 
FLECS_API ECS_COMPONENT_DECLARE (EcsAlert)
 Tag added to alert, and used as first element of alert severity pair.
 
FLECS_API ECS_COMPONENT_DECLARE (EcsAlertInstance)
 
FLECS_API ECS_COMPONENT_DECLARE (EcsAlertsActive)
 
FLECS_API ECS_COMPONENT_DECLARE (EcsAlertTimeout)
 
FLECS_API ECS_TAG_DECLARE (EcsAlertInfo)
 
FLECS_API ECS_TAG_DECLARE (EcsAlertWarning)
 
FLECS_API ECS_TAG_DECLARE (EcsAlertError)
 
FLECS_API ECS_TAG_DECLARE (EcsAlertCritical)
 
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)
 

Detailed Description

Create alerts from monitoring queries.

Macro Definition Documentation

◆ ecs_alert

#define ecs_alert ( world,
... )    ecs_alert_init(world, &(ecs_alert_desc_t)__VA_ARGS__)

Definition at line 163 of file alerts.h.

◆ ECS_ALERT_MAX_SEVERITY_FILTERS

#define ECS_ALERT_MAX_SEVERITY_FILTERS   (4)

Definition at line 35 of file alerts.h.

Typedef Documentation

◆ EcsAlertInstance

typedef struct EcsAlertInstance EcsAlertInstance

Alert information.

Added to each alert instance

Function Documentation

◆ ecs_alert_init()

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:

  • AlertInstance: contains the alert message for the instance
  • MetricSource: contains the entity that triggered the alert
  • MetricValue: contains how long the alert has been active

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.

Parameters
worldThe world.
descAlert description.
Returns
The alert entity.

◆ ecs_get_alert()

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.

Parameters
worldThe world.
entityThe entity.
alertThe alert to test for.
Returns
The alert instance for the specified alert.

◆ ecs_get_alert_count()

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.

Parameters
worldThe world.
entityThe entity.
alertThe alert to test for (optional).
Returns
The number of active alerts for the entity.