]> git.ipfire.org Git - telemetry.git/commitdiff
graph: Fix return code mess for render check
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 10 Jul 2026 14:26:47 +0000 (14:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 10 Jul 2026 14:26:47 +0000 (14:26 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/graph.c

index 695f3581ad1a1e703a7756293260b9f5ecb7ebdc..3ae9f0a4f1220c685d6aba95336227d4d0237bc4 100644 (file)
@@ -234,6 +234,7 @@ int td_graph_requires_source(td_graph* self, const char* name, const char* objec
                switch (r) {
                        // No match
                        case 0:
+                               DEBUG(self->ctx, "Cannot find object '%s' for source '%s'\n", object, name);
                                r = -ENODATA;
                                goto ERROR;
 
@@ -373,7 +374,7 @@ int td_graph_can_render(td_graph* self, const char* object,
                const td_graph_render_options* options) {
        // If we don't have a check function, we just assume that we can render
        if (!self->impl->can_render)
-               return 1;
+               return 0;
 
        // Check if this can be rendered
        return self->impl->can_render(self->ctx, self, options, object);
@@ -400,8 +401,11 @@ int td_graph_render(td_graph* self, const char* object,
        clock_t t_start = 0;
        clock_t t_end = 0;
 
+       // Fetch the graph name
+       const char* name = td_graph_get_name(self);
+
        // Log action
-       DEBUG(self->ctx, "Rendering %s...\n", td_graph_get_name(self));
+       DEBUG(self->ctx, "Rendering %s...\n", name);
 
        // Fail if we don't have a render function
        if (!self->impl->render)
@@ -410,17 +414,20 @@ int td_graph_render(td_graph* self, const char* object,
        // Check if this can be rendered
        r = td_graph_can_render(self, object, options);
        switch (r) {
-               // Cannot render
+               // Can render
                case 0:
-                       r = -ENODATA;
-                       goto ERROR;
+                       DEBUG(self->ctx, "%s can be rendered\n", name);
+                       break;
 
-               // Can render
+               // Cannot render
                case 1:
-                       break;
+                       ERROR(self->ctx, "%s cannot be rendered\n", name);
+                       r = -ENODATA;
+                       goto ERROR;
 
                // Raise any errors
                default:
+                       ERROR(self->ctx, "Render check for %s failed: %s\n", name, strerror(-r));
                        goto ERROR;
        }