Skip to content

File syn_metrics.h

FileList > src > syntropic > util > syn_metrics.h

Go to the source code of this file

Lightweight telemetry and metrics (Counter/Gauge). More...

  • #include "../common/syn_defs.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_Metric
Metric descriptor and storage.

Public Types

Type Name
enum SYN_MetricType
Type of value stored in a metric.
union SYN_MetricVal
Internal union for metric values.

Public Static Functions

Type Name
void syn_metrics_count (const char * name, int32_t delta)
void syn_metrics_foreach (void(*)(const struct SYN_Metric *m, void *ctx) cb, void * ctx)
Iterate over all registered metrics (no-op when disabled).
void syn_metrics_init (void)
void syn_metrics_record (const char * name, float value)

Macros

Type Name
define SYN_METRIC_ADD (m, v) ((void)0)
Add value to a metric (disabled).
define SYN_METRIC_DEC (m) ((void)0)
Decrement a metric (disabled).
define SYN_METRIC_DECLARE (var, name, help, type)
Declare a metric statically (disabled).
define SYN_METRIC_INC (m) ((void)0)
Increment a metric (disabled).
define SYN_METRIC_REGISTER (m) ((void)0)
Register a metric (disabled).
define SYN_METRIC_SET (m, v) ((void)0)
Set a metric value (disabled).
define SYN_METRIC_SUB (m, v) ((void)0)
Subtract value from a metric (disabled).

Detailed Description

This module follows an opt-in pattern. If SYN_USE_METRICS is not defined or is 0, all macros expand to nothing, resulting in zero overhead.

Public Types Documentation

enum SYN_MetricType

Type of value stored in a metric.

enum SYN_MetricType {
    SYN_METRIC_TYPE_COUNTER,
    SYN_METRIC_TYPE_GAUGE
};


union SYN_MetricVal

Internal union for metric values.



Public Static Functions Documentation

function syn_metrics_count

static inline void syn_metrics_count (
    const char * name,
    int32_t delta
) 

function syn_metrics_foreach

Iterate over all registered metrics (no-op when disabled).

static inline void syn_metrics_foreach (
    void(*)(const struct SYN_Metric *m, void *ctx) cb,
    void * ctx
) 

Parameters:

  • cb Callback.
  • ctx Context.

function syn_metrics_init

static inline void syn_metrics_init (
    void
) 

function syn_metrics_record

static inline void syn_metrics_record (
    const char * name,
    float value
) 

Macro Definition Documentation

define SYN_METRIC_ADD

Add value to a metric (disabled).

#define SYN_METRIC_ADD (
    m,
    v
) `((void)0)`


define SYN_METRIC_DEC

Decrement a metric (disabled).

#define SYN_METRIC_DEC (
    m
) `((void)0)`


define SYN_METRIC_DECLARE

Declare a metric statically (disabled).

#define SYN_METRIC_DECLARE (
    var,
    name,
    help,
    type
) 


define SYN_METRIC_INC

Increment a metric (disabled).

#define SYN_METRIC_INC (
    m
) `((void)0)`


define SYN_METRIC_REGISTER

Register a metric (disabled).

#define SYN_METRIC_REGISTER (
    m
) `((void)0)`


define SYN_METRIC_SET

Set a metric value (disabled).

#define SYN_METRIC_SET (
    m,
    v
) `((void)0)`


define SYN_METRIC_SUB

Subtract value from a metric (disabled).

#define SYN_METRIC_SUB (
    m,
    v
) `((void)0)`



The documentation for this class was generated from the following file src/syntropic/util/syn_metrics.h