]> git.ipfire.org Git - telemetry.git/commitdiff
sources: Rename collect() to heartbeat()
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Oct 2025 09:43:26 +0000 (09:43 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Oct 2025 09:43:26 +0000 (09:43 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 files changed:
src/daemon/source.c
src/daemon/source.h
src/daemon/sources/conntrack.c
src/daemon/sources/contextswitches.c
src/daemon/sources/df.c
src/daemon/sources/ipfrag4.c
src/daemon/sources/loadavg.c
src/daemon/sources/memory.c
src/daemon/sources/pressure-cpu.c
src/daemon/sources/pressure-io.c
src/daemon/sources/pressure-memory.c
src/daemon/sources/processor.c
src/daemon/sources/softirq.c
src/daemon/sources/test-error.c
src/daemon/sources/test-flapping.c
src/daemon/sources/test-stall.c
src/daemon/sources/unbound.c
src/daemon/sources/uptime.c

index 04678dec18b2a839f69c8df729afce6efb11d43b..5000da2839686ac5b91cc721755c7d7ee8483bbc 100644 (file)
@@ -281,10 +281,10 @@ static int collecty_source_heartbeat(sd_event_source* source, uint64_t usec, voi
                        collecty_source_name(self), USEC_TO_MSEC((double)t_delay));
        }
 
-       // Call the collect method
-       r = self->impl->collect(self->ctx, self);
+       // Call the heartbeat method
+       r = self->impl->heartbeat(self->ctx, self);
        if (r < 0) {
-               ERROR(self->ctx, "collect() failed for %s: %s\n",
+               ERROR(self->ctx, "heartbeat() failed for %s: %s\n",
                        collecty_source_name(self), strerror(-r));
        }
 
@@ -332,8 +332,8 @@ static int collecty_source_register_heartbeat(collecty_source* self) {
        uint64_t heartbeat = 0;
        int r;
 
-       // No need to do this if we don't have a collect method
-       if (!self->impl->collect)
+       // No need to do this if we don't have a heartbeat method
+       if (!self->impl->heartbeat)
                return 0;
 
        // To avoid any load peaks, stagger sources
index dfe34e43019d822e00b67920d770b9b80f7a94fe..289850148bf3acf749d1033aae742eb064284cd5 100644 (file)
@@ -67,8 +67,8 @@ typedef struct collecty_source_impl {
        // Free
        int (*free)(collecty_ctx* ctx);
 
-       // Collect
-       int (*collect)(collecty_ctx* ctx, collecty_source* source);
+       // Heartbeat
+       int (*heartbeat)(collecty_ctx* ctx, collecty_source* source);
 } collecty_source_impl;
 
 int collecty_source_create(collecty_source** source,
index e3dd4186ef599134912fc9ca4e482e62191690fc..033b46b0ee80db4e3935c19970da6498b39cf90d 100644 (file)
@@ -25,7 +25,7 @@
 #include "../util.h"
 #include "conntrack.h"
 
-static int conntrack_collect(collecty_ctx* ctx, collecty_source* source) {
+static int conntrack_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        uint64_t count = 0;
        uint64_t max = 0;
        int r;
@@ -61,5 +61,5 @@ const collecty_source_impl conntrack_source = {
        },
 
        // Methods
-       .collect = conntrack_collect,
+       .heartbeat = conntrack_heartbeat,
 };
index 6dd891f530a7113416a20d4a41fd2f117095f9ff..09987bee0b8436e7f59e2f057cde03a4af338bb6 100644 (file)
@@ -88,7 +88,7 @@ static int contextswitches_free(collecty_ctx* ctx) {
        return 0;
 }
 
-static int contextswitches_collect(collecty_ctx* ctx, collecty_source* source) {
+static int contextswitches_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        long long total = 0;
        uint64_t count = 0;
        int fd = -EBADF;
@@ -127,7 +127,7 @@ const collecty_source_impl contextswitches_source = {
        },
 
        // Methods
-       .init    = contextswitches_init,
-       .free    = contextswitches_free,
-       .collect = contextswitches_collect,
+       .init      = contextswitches_init,
+       .free      = contextswitches_free,
+       .heartbeat = contextswitches_heartbeat,
 };
index ce4040fc2ce372da5472d50d4d6a8df3e4114dc4..8d3c59634bd1d4aa85e278ae64cfe8479a28cb90 100644 (file)
@@ -26,7 +26,7 @@
 #include "../source.h"
 #include "df.h"
 
-static int df_collect(collecty_ctx* ctx, collecty_source* source) {
+static int df_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        struct mntent* mountpoint = NULL;
        struct statvfs stat = {};
        FILE* f = NULL;
@@ -97,5 +97,5 @@ const collecty_source_impl df_source = {
        },
 
        // Methods
-       .collect = df_collect,
+       .heartbeat = df_heartbeat,
 };
index ca96dee1a622bb198bf2fd3ab7d71f2a3ee18cf9..4907fefe44c28a8926dd877d64a2a1b4335cebaa 100644 (file)
@@ -23,7 +23,7 @@
 #include "../source.h"
 #include "ipfrag4.h"
 
-static int ipfrag4_collect(collecty_ctx* ctx, collecty_source* source) {
+static int ipfrag4_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        collecty_proto* proto = NULL;
        uint64_t frags_oks;
        uint64_t frags_fails;
@@ -113,5 +113,5 @@ const collecty_source_impl ipfrag4_source = {
        },
 
        // Methods
-       .collect = ipfrag4_collect,
+       .heartbeat = ipfrag4_heartbeat,
 };
index b14d16f628b4b7d91fe3ef6b0aae807683ab6d84..d96044ac75e8b671f5a98e9779ba46512ce33457 100644 (file)
@@ -24,7 +24,7 @@
 #include "../source.h"
 #include "loadavg.h"
 
-static int loadavg_collect(collecty_ctx* ctx, collecty_source* source) {
+static int loadavg_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        double loadavg[3];
        int r;
 
@@ -50,5 +50,5 @@ const collecty_source_impl loadavg_source = {
        },
 
        // Methods
-       .collect = loadavg_collect,
+       .heartbeat = loadavg_heartbeat,
 };
index dd06f1bfd000456236c1d6c5254ff39868ed4f32..d74099d8b51b69a35c907a300dd07f2b9c034a7a 100644 (file)
@@ -23,7 +23,7 @@
 #include "../source.h"
 #include "memory.h"
 
-static int memory_collect(collecty_ctx* ctx, collecty_source* source) {
+static int memory_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        collecty_proc_meminfo meminfo = {};
        int r;
 
@@ -71,5 +71,5 @@ const collecty_source_impl memory_source = {
        },
 
        // Methods
-       .collect = memory_collect,
+       .heartbeat = memory_heartbeat,
 };
index 8bcbccad1a7aee6dac9a777ba7aef9e71f1a3abb..5afcd279aa30bd9ce292f34694fd081e2bf350e5 100644 (file)
@@ -23,7 +23,7 @@
 #include "../source.h"
 #include "pressure-cpu.h"
 
-static int pressure_cpu_collect(collecty_ctx* ctx, collecty_source* source) {
+static int pressure_cpu_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        collecty_pressure_stats stats = {};
        int r;
 
@@ -58,5 +58,5 @@ const collecty_source_impl pressure_cpu_source = {
        },
 
        // Methods
-       .collect = pressure_cpu_collect,
+       .heartbeat = pressure_cpu_heartbeat,
 };
index a005c28ca2bd3a6238e33ffb1e98c2bc5d0f3754..2e21c77616da2f27d23b1e7c71ed11dd28f90c70 100644 (file)
@@ -23,7 +23,7 @@
 #include "../source.h"
 #include "pressure-io.h"
 
-static int pressure_io_collect(collecty_ctx* ctx, collecty_source* source) {
+static int pressure_io_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        collecty_pressure_stats stats = {};
        int r;
 
@@ -58,5 +58,5 @@ const collecty_source_impl pressure_io_source = {
        },
 
        // Methods
-       .collect = pressure_io_collect,
+       .heartbeat = pressure_io_heartbeat,
 };
index 13e0456f426d07d43166a047cd3c0f062806ec3e..89dc4844f2b6a1c5531924597417936f53ee77e0 100644 (file)
@@ -23,7 +23,7 @@
 #include "../source.h"
 #include "pressure-memory.h"
 
-static int pressure_memory_collect(collecty_ctx* ctx, collecty_source* source) {
+static int pressure_memory_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        collecty_pressure_stats stats = {};
        int r;
 
@@ -58,5 +58,5 @@ const collecty_source_impl pressure_memory_source = {
        },
 
        // Methods
-       .collect = pressure_memory_collect,
+       .heartbeat = pressure_memory_heartbeat,
 };
index 1617870fb09d702f710576ead71c2fe6404d1d21..d85ac61c6b7c35960b769ba9901613882789a70b 100644 (file)
@@ -26,7 +26,7 @@
 // /proc/stat currently carries 10 fields
 #define MAX_FIELDS 10
 
-static int processor_collect(collecty_ctx* ctx, collecty_source* source) {
+static int processor_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        unsigned long usage[MAX_FIELDS] = {};
        int r;
 
@@ -61,5 +61,5 @@ const collecty_source_impl processor_source = {
        },
 
        // Methods
-       .collect = processor_collect,
+       .heartbeat = processor_heartbeat,
 };
index 55cdff505397da5169d0adc2d3bb2dadb24d7d7a..7a2fe66668c86dd2634272844d741856b699dd58 100644 (file)
@@ -30,7 +30,7 @@ static int callback(collecty_ctx* ctx, const char* key, uint64_t value, void* da
        return collecty_source_submit(source, key, "%lu", value);
 }
 
-static int softirq_collect(collecty_ctx* ctx, collecty_source* source) {
+static int softirq_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        return collecty_proc_read_softirq(ctx, callback, source);
 }
 
@@ -44,5 +44,5 @@ const collecty_source_impl softirq_source = {
        },
 
        // Methods
-       .collect = softirq_collect,
+       .heartbeat = softirq_heartbeat,
 };
index bd6b864121fe516b4a1a8343748f225f360955d6..58b95def8011a557cad20cc6e2cb61a4f389c1f9 100644 (file)
@@ -28,7 +28,7 @@
        This is a test source which always fails.
 */
 
-static int test_error_collect(collecty_ctx* ctx, collecty_source* source) {
+static int test_error_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        return -ENOSPC;
 }
 
@@ -36,5 +36,5 @@ const collecty_source_impl test_error_source = {
        .name    = "test-error",
 
        // Methods
-       .collect = test_error_collect,
+       .heartbeat = test_error_heartbeat,
 };
index 860e563b0613b4cbcaa9310ad54740a03120cb93..f4decd51fe4e1cf8435906c08f5821d28ee56c84 100644 (file)
@@ -29,7 +29,7 @@
        This is a test source which fails with a certain probability.
 */
 
-static int test_flapping_collect(collecty_ctx* ctx, collecty_source* source) {
+static int test_flapping_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        int r;
 
        // Fetch some random value
@@ -53,5 +53,5 @@ const collecty_source_impl test_flapping_source = {
        },
 
        // Methods
-       .collect = test_flapping_collect,
+       .heartbeat = test_flapping_heartbeat,
 };
index 87306537f5e8295777865719d0c0b5b9bfeecc30..fba82d8b176eebfa3c41f9ee491e6f7bc865fb69 100644 (file)
@@ -27,7 +27,7 @@
        This is a test stalls the event loop.
 */
 
-static int test_stall_collect(collecty_ctx* ctx, collecty_source* source) {
+static int test_stall_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        // Sleep for 500ms
        return usleep(MSEC_TO_USEC(500));
 }
@@ -36,5 +36,5 @@ const collecty_source_impl test_stall_source = {
        .name    = "test-stall",
 
        // Methods
-       .collect = test_stall_collect,
+       .heartbeat = test_stall_heartbeat,
 };
index b326bd30cb514cc589d75dad255d450f518a7020..df53aad721a2b93bd36ba9ebcff4d77ebad27ea1 100644 (file)
@@ -97,7 +97,7 @@ static int unbound_on_success(collecty_ctx* ctx,
                stats.rec_replies, stats.rec_time_avg, stats.rec_time_median);
 }
 
-static int unbound_collect(collecty_ctx* ctx, collecty_source* source) {
+static int unbound_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        collecty_command* command = NULL;
        int r;
 
@@ -138,5 +138,5 @@ const collecty_source_impl unbound_source = {
        },
 
        // Methods
-       .collect = unbound_collect,
+       .heartbeat = unbound_heartbeat,
 };
index 69e64bb707c01275da053ea1f4ff80127e914ed7..1a3f9e116ea29d45bd2c2fa90e4c882d00b7e0d4 100644 (file)
@@ -25,7 +25,7 @@
 #include "../source.h"
 #include "uptime.h"
 
-static int uptime_collect(collecty_ctx* ctx, collecty_source* source) {
+static int uptime_heartbeat(collecty_ctx* ctx, collecty_source* source) {
        struct sysinfo info = {};
        int r;
 
@@ -48,5 +48,5 @@ const collecty_source_impl uptime_source = {
        },
 
        // Methods
-       .collect = uptime_collect,
+       .heartbeat = uptime_heartbeat,
 };