summaryrefslogtreecommitdiff
path: root/ref/api/stats.html
diff options
context:
space:
mode:
authorgdamore <gdamore@users.noreply.github.com>2024-12-31 17:51:33 +0000
committergdamore <gdamore@users.noreply.github.com>2024-12-31 17:51:33 +0000
commit3e3dd5ef9bec1db07bcb340691b58af9099446cd (patch)
tree186b9b1bd1c35a1ee5033410876b044f8005ce0c /ref/api/stats.html
parent024f133aed0ff43fb01e9a19458a05e04510db82 (diff)
downloadnng-3e3dd5ef9bec1db07bcb340691b58af9099446cd.tar.gz
nng-3e3dd5ef9bec1db07bcb340691b58af9099446cd.tar.bz2
nng-3e3dd5ef9bec1db07bcb340691b58af9099446cd.zip
deploy: c3bb282e916bf1ece77bf81901878498e39f0017
Diffstat (limited to 'ref/api/stats.html')
-rw-r--r--ref/api/stats.html45
1 files changed, 24 insertions, 21 deletions
diff --git a/ref/api/stats.html b/ref/api/stats.html
index 9b1f56dc..83c8b4a3 100644
--- a/ref/api/stats.html
+++ b/ref/api/stats.html
@@ -272,6 +272,7 @@ through <em>statsp</em> using the function <code>nng_stats_get</code>.</p>
<h2 id="traversing-the-tree"><a class="header" href="#traversing-the-tree">Traversing the Tree</a></h2>
<pre><code class="language-c">const nng_stat *nng_stat_child(const nng_stat *stat);
const nng_stat *nng_stat_next(const nng_stat *stat);
+const nng_stat *nng_stat_parent(const nng_stat *stat);
</code></pre>
<p>Traversing the tree of statistics is done using the <a name="a005"></a><code>nng_stat_child</code> and
<a name="a006"></a><code>nng_stat_next</code> functions.</p>
@@ -279,6 +280,8 @@ const nng_stat *nng_stat_next(const nng_stat *stat);
or <code>NULL</code> if the <em>stat</em> has no children.</p>
<p>The <code>nng_stat_next</code> function returns the nearest sibling to the right of <em>stat</em>,
or <code>NULL</code> if <em>stat</em> has no more siblings to the right.</p>
+<p>The <a name="a007"></a><code>nng_stat_parent</code> function returns the parent of <em>stat</em>, or <code>NULL</code> if
+<em>stat</em> is the root of the statistics tree.</p>
<h2 id="finding-a-statistic"><a class="header" href="#finding-a-statistic">Finding a Statistic</a></h2>
<pre><code class="language-c">const nng_stat *nng_stat_find(const nng_stat *stat, const char *name);
const nng_stat *nng_stat_find_dialer(const nng_stat *stat, nng_dialer dialer);
@@ -289,10 +292,10 @@ const nng_stat *nng_stat_find_socket(const nng_stat *stat, nng_dialer socket);
or possibly to find the tree of statistics associated iwth a specific <a href="/TODO.html">socket</a>,
<a href="/TODO.html">dialer</a>, or <a href="/TODO.html">listener</a>.</p>
<p>The <code>nng_stat_find</code> functions are provided for this purpose.</p>
-<p>The <a name="a007"></a><code>nng_stat_find</code> function returns the first statistic within the subtree of
+<p>The <a name="a008"></a><code>nng_stat_find</code> function returns the first statistic within the subtree of
statistics <em>stat</em>, with the given <em>name</em>. If no such statistic can be found, <code>NULL</code>
is returned.</p>
-<p>The <a name="a008"></a><code>nng_stat_find_dialer</code>, <a name="a009"></a><code>nng_stat_find_listener</code>, and <a name="a010"></a><code>nng_stat_find_socket</code>
+<p>The <a name="a009"></a><code>nng_stat_find_dialer</code>, <a name="a010"></a><code>nng_stat_find_listener</code>, and <a name="a011"></a><code>nng_stat_find_socket</code>
return the statistics subtree for the given dialer, listener, or socket object. If no such
statistic can be found, then they return <code>NULL</code>.
These functions should be provided the root of the statistic tree, in order to ensure
@@ -301,23 +304,23 @@ that they can find the desired object.</p>
<pre><code class="language-c">const char *nng_stat_name(const nng_stat *stat);
const char *nng_stat_desc(const nng_stat *stat);
</code></pre>
-<p>Every statistic has a name, returned by <a name="a011"></a><code>nng_stat_name</code>, and a description, returned by
-<a name="a012"></a><code>nng_stat_desc</code>. Descriptions are human-readable text, which might be useful for display.</p>
+<p>Every statistic has a name, returned by <a name="a012"></a><code>nng_stat_name</code>, and a description, returned by
+<a name="a013"></a><code>nng_stat_desc</code>. Descriptions are human-readable text, which might be useful for display.</p>
<h2 id="statistic-type"><a class="header" href="#statistic-type">Statistic Type</a></h2>
<pre><code class="language-c">int nng_stat_type(const nng_stat *stat);
</code></pre>
-<p>The function <a name="a013"></a><code>nng_stat_type</code> returns the type of the statistic.
+<p>The function <a name="a014"></a><code>nng_stat_type</code> returns the type of the statistic.
The type of a statistic determines the nature of the value, and which
function can be used to obtain that value.</p>
<ul>
<li>
-<p><a name="a014"></a><code>NNG_STAT_SCOPE</code>: <a name="NNG_STAT_SCOPE"></a>
+<p><a name="a015"></a><code>NNG_STAT_SCOPE</code>: <a name="NNG_STAT_SCOPE"></a>
The statistic does not carry any real value, but is
used for grouping related statistics together. This is a nexus in the
statistics tree.</p>
</li>
<li>
-<p><a name="a015"></a><code>NNG_STAT_COUNTER</code>: <a name="NNG_STAT_COUNTER"></a>
+<p><a name="a016"></a><code>NNG_STAT_COUNTER</code>: <a name="NNG_STAT_COUNTER"></a>
The statistic is a counter that only increments.
Usually the change in the value of the statistic is more interesting
(as a rate) than the absolute value at any given time. The value should
@@ -325,7 +328,7 @@ be obtained using <a href="/api/stats.html#statistic-value"><code>nng_stat_value
The units will be given by the value returned from <a href="/api/stats.html#statistic-units"><code>nng_stat_unit</code></a>.</p>
</li>
<li>
-<p><a name="a016"></a><code>NNG_STAT_LEVEL</code>: <a name="NNG_STAT_LEVEL"></a>
+<p><a name="a017"></a><code>NNG_STAT_LEVEL</code>: <a name="NNG_STAT_LEVEL"></a>
The statistic represnts a measured value which corresponds
to a specific value at a specific time. For example, this may represent the
number of messages currently queued for some operation, or the link speed
@@ -335,19 +338,19 @@ than the change in the value over time. Again the value can be obtained with
with <a href="/api/stats.html#statistic-units"><code>nng_stat_unit</code></a>.</p>
</li>
<li>
-<p><a name="a017"></a><code>NNG_STAT_STRING</code>: <a name="NNG_STAT_STRING"></a>
+<p><a name="a018"></a><code>NNG_STAT_STRING</code>: <a name="NNG_STAT_STRING"></a>
The statistic is a string, such as a name. The value
of the string can be obtained with <a href="/api/stats.html#statistic-value"><code>nng_stat_string</code></a>.
The value of this string
will remain valid until the snapshot is deallocated with <a href="/api/stats.html#freeing-a-snapshot"><code>nng_stats_free</code></a>.</p>
</li>
<li>
-<p><a name="a018"></a><code>NNG_STAT_BOOLEAN</code>: <a name="NNG_STAT_BOOLEAN"></a>
+<p><a name="a019"></a><code>NNG_STAT_BOOLEAN</code>: <a name="NNG_STAT_BOOLEAN"></a>
The value of the statistic is a truth value (either <code>true</code>
or <code>false</code>) and can be obtained with <a href="/api/stats.html#statistic-value"><code>nng_stat_bool</code></a>.</p>
</li>
<li>
-<p><a name="a019"></a><code>NNG_STAT_ID</code>: <a name="NNG_STAT_ID"></a>
+<p><a name="a020"></a><code>NNG_STAT_ID</code>: <a name="NNG_STAT_ID"></a>
The value of the statistic is a numeric identifier, such as a socket
identifier. The value can be obtained with <a href="/api/stats.html#statistic-value"><code>nng_stat_value</code></a>,
and will be fixed for the life of the statistic.</p>
@@ -359,12 +362,12 @@ const char *nng_stat_string(const nng_stat *stat);
bool nng_stat_bool(const nng_stat *stat);
</code></pre>
<p>These functions return the value associated with the statistic.</p>
-<p>The <a name="a020"></a><code>nng_stat_value</code> function returns the the numeric value for the statistic <em>stat</em>
+<p>The <a name="a021"></a><code>nng_stat_value</code> function returns the the numeric value for the statistic <em>stat</em>
of type <a href="/api/stats.html#NNG_STAT_COUNTER"><code>NNG_STAT_COUNTER</code></a>, <a href="/api/stats.html#NNG_STAT_LEVEL"><code>NNG_STAT_LEVEL</code></a>, or <a href="/api/stats.html#NNG_STAT_ID"><code>NNG_STAT_ID</code></a>.
If <em>stat</em> is not one of these types, then it returns zero.</p>
-<p>The <a name="a021"></a><code>nng_stat_bool</code> function returns the Boolean value (either <code>true</code> or <code>false</code>) for the statistic <em>stat</em> of
+<p>The <a name="a022"></a><code>nng_stat_bool</code> function returns the Boolean value (either <code>true</code> or <code>false</code>) for the statistic <em>stat</em> of
type <a href="/api/stats.html#NNG_STAT_BOOLEAN"><code>NNG_STAT_BOOLEAN</code></a>. If the statistics is not of this type, then it returns <code>false</code>.</p>
-<p>The <a name="a022"></a><code>nng_stat_string</code> function returns a pointer to a string value for the statistic <em>stat</em>,
+<p>The <a name="a023"></a><code>nng_stat_string</code> function returns a pointer to a string value for the statistic <em>stat</em>,
of type <a href="/api/stats.html#statistic-value"><code>NNG_STAT_STRING</code></a>. This string will remain valud until the snapshot that
<em>stat</em> was collected with is deallocated with <a href="/api/stats.html#freeing-a-snapshot"><code>nng_stats_free</code></a>. If the statistic
is not of type <code>NNG_STAT_STRING</code>, then <code>NULL</code> is returned.</p>
@@ -373,19 +376,19 @@ is not of type <code>NNG_STAT_STRING</code>, then <code>NULL</code> is returned.
</code></pre>
<p>For statistics of type <a href="/api/stats.html#NNG_STAT_COUNTER"><code>NNG_STAT_COUNTER</code></a> or <a href="/api/stats.html#NNG_STAT_LEVEL"><code>NNG_STAT_LEVEL</code></a>,
it is often useful to know what that quantity being reported measures.
-The following units may be returned from <a name="a023"></a><code>nng_stat_unit</code> for such a statistic:</p>
+The following units may be returned from <a name="a024"></a><code>nng_stat_unit</code> for such a statistic:</p>
<ul>
-<li><a name="a024"></a><code>NNG_UNIT_NONE</code>: No unit is known or applies.</li>
-<li><a name="a025"></a><code>NNG_UNIT_BYTES</code>: A count of bytes.</li>
-<li><a name="a026"></a><code>NNG_UNIT_MESSAGES</code>: A count of messages.</li>
-<li><a name="a027"></a><code>NNG_UNIT_MILLIS</code>: A count of milliseconds.</li>
-<li><a name="a028"></a><code>NNG_UNIT_EVENTS</code>: A count of events of some type.</li>
+<li><a name="a025"></a><code>NNG_UNIT_NONE</code>: No unit is known or applies.</li>
+<li><a name="a026"></a><code>NNG_UNIT_BYTES</code>: A count of bytes.</li>
+<li><a name="a027"></a><code>NNG_UNIT_MESSAGES</code>: A count of messages.</li>
+<li><a name="a028"></a><code>NNG_UNIT_MILLIS</code>: A count of milliseconds.</li>
+<li><a name="a029"></a><code>NNG_UNIT_EVENTS</code>: A count of events of some type.</li>
</ul>
<h2 id="statistic-timestamp"><a class="header" href="#statistic-timestamp">Statistic Timestamp</a></h2>
<pre><code class="language-c">uint64_t nng_stat_timestamp(const nng_stat *stat);
</code></pre>
<p>Statistics have a timestamp indicating when the value was sampled,
-obtained via <a name="a029"></a><code>nng_stat_timestamp</code>. The timestamp is given in
+obtained via <a name="a030"></a><code>nng_stat_timestamp</code>. The timestamp is given in
in milliseconds since a reference time, and the reference time used
here is the same reference time used for <a href="/api/time.html#get-the-current-time"><code>nng_clock</code></a>.</p>
<h2 id="see-also"><a class="header" href="#see-also">See Also</a></h2>