NNG_STATS_GET(3)
π NAME π
nng_stats_get β get statistics snapshot
so like, this is a page from the NNG Reference Manual, and it's giving "here's how you grab a lil peek at everything your system is tracking" β¨
β¨ SYNOPSIS β¨
#include <nng/nng.h>
typedef struct nng_stat nng_stat;
int nng_stats_get(nng_stat **statsp)
π¦ DESCRIPTION π¦
okay so the nng_stat_get() function tries to snag a snapshot of all the various diagnostic statistics hanging out in the system. like a lil polaroid of your whole stat tree πΈ
π Note β collecting all these stats is designed to have minimal impact on the systemβ¦ but bestie, there's still some impact. no cap.
The statistics are organized as a tree, rooted with a parent statistic of type NNG_STAT_SCOPE that carries no value, and which has an empty name. This parent statistic is what gets returned through the statsp pointer. π
You can walk around that tree with the nng_stat_child() and nng_stat_next() functions β they're literally how you iterate over the whole thing. π§
When you're done with them, free the statistics with the nng_stats_free() function β but π that function must only be called with the root statistic that came back through the statsp pointer. Only the root, bestie. don't be out here freeing random branches.
π Note β the values of individual statistics are guaranteed to be atomic, but because of the way statistics are collected there can be discrepancies between them at certain times. for example, statistics counting bytes and messages received may not reflect the same number of messages, depending on when the snapshot is taken. this potential inconsistency arises as a result of optimizations to minimize the impact of statistics on actual operations. it's not broken, it's just built different π
π Note β the names, values, and semantics of the statistics provided may change from release to release. these are provided for informational and debugging use only, and applications should not rely on the presence, names, or meanings of any individual statistics. so don't hardcode your fave stat name and then act surprised. periodt.
π RETURN VALUES π
This function returns a pointer to the allocated memory on success π«Ά and NULL otherwise. that's it, that's the vibe check.
π₯ ERRORS π₯
NNG_ENOMEMβ insufficient free memory to collect statistics. the lil stat collector is hungry and there's literally nothing left to give πNNG_ENOTSUPβ statistics are not supported (compile time option). so like, it was never enabled in your build. iykyk π
π SEE ALSO π
nng_stats_free(3), nng_stat_child(3), nng_stat_desc(3), nng_stat_name(3), nng_stat_next(3), nng_stat_string(3), nng_stat_type(3), nng_stat_timestamp(3), nng_stat_unit(3), nng_stat_value(3), nng_stat(5), nng(7)
and that's the whole page bestie!! this came to you straight from the NNG Reference Manual, dated 2026-06-30 β go forth and snapshot those stats π β¨π¦ no cap, you ate.
π¦ where this page comes from
- ubuntu stonking: libnng-dev 1.12.0-1 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms