]> git.ipfire.org Git - telemetry.git/commitdiff
graphs: Extend implemention to check if a graph can be rendered
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Jun 2026 15:10:06 +0000 (15:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Jun 2026 15:10:06 +0000 (15:10 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/graph.c
src/daemon/graph.h

index 9d7001b4fdf65605cf1d7f651d229b0185a9686f..51caa462b8df218adb16a294e5466f699911c8f5 100644 (file)
@@ -336,6 +336,13 @@ int td_graph_render(td_graph* self, const char* object,
        if (!self->impl->render)
                return -ENOTSUP;
 
+       // Check if this can be rendered
+       if (self->impl->can_render) {
+               r = self->impl->can_render(self->ctx, self, options, object);
+               if (r < 0)
+                       goto ERROR;
+       }
+
        // Store the start time
        t_start = clock();
        if (t_start < 0) {
index 5890dc64983046ab952965ceee55b17fbaee41e0..0a86d8400df5cfcba1b9052516af39f1b457a2b6 100644 (file)
@@ -72,6 +72,10 @@ typedef struct td_graph_impl {
        // Available
        int (*available)(td_ctx* ctx, td_daemon* daemon);
 
+       // Can Render?
+       int (*can_render)(td_ctx* ctx, td_graph* graph,
+               const td_graph_render_options* options, const char* object);
+
        // Render!
        int (*render)(td_ctx* ctx, td_graph* graph, const td_graph_render_options* options,
                td_args* args, const char* object);