ORE Studio 0.0.4
Loading...
Searching...
No Matches
telemetry_protocol.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_COMPUTE_MESSAGING_TELEMETRY_PROTOCOL_HPP
21#define ORES_COMPUTE_MESSAGING_TELEMETRY_PROTOCOL_HPP
22
23#include <string>
24#include <string_view>
25#include <vector>
26#include <cstdint>
27
28namespace ores::compute::messaging {
29
30// =============================================================================
31// Dashboard stats query (request/reply)
32// =============================================================================
33
34struct get_grid_stats_request {
35 using response_type = struct get_grid_stats_response;
36 static constexpr std::string_view nats_subject =
37 "compute.v1.telemetry.get_grid_stats";
38};
39
40struct node_stats_summary {
41 std::string host_id;
42 int tasks_completed{0};
43 int tasks_since_last{0};
44 std::int64_t avg_task_duration_ms{0};
45 std::int64_t input_bytes_fetched{0};
46 std::int64_t output_bytes_uploaded{0};
47 int seconds_since_hb{0};
48};
49
50struct get_grid_stats_response {
51 bool success{false};
52 std::string message;
53
54 // Grid-level fields (mirrors domain::grid_sample)
55 int total_hosts{0};
56 int online_hosts{0};
57 int idle_hosts{0};
58
59 int results_inactive{0};
60 int results_unsent{0};
61 int results_in_progress{0};
62 int results_done{0};
63
64 int total_workunits{0};
65 int total_batches{0};
66 int active_batches{0};
67
68 int outcomes_success{0};
69 int outcomes_client_error{0};
70 int outcomes_no_reply{0};
71
73 std::string sampled_at;
74
76 std::vector<node_stats_summary> node_summaries;
77};
78
79// =============================================================================
80// Per-node sample publish (fire-and-forget from wrapper → service)
81// =============================================================================
82
83struct node_sample_message {
84 static constexpr std::string_view nats_subject =
85 "compute.v1.telemetry.node_samples";
86
87 std::string tenant_id;
88 std::string host_id;
89 std::string sampled_at; // ISO-8601
90
91 int tasks_completed{0};
92 int tasks_failed{0};
93 int tasks_since_last{0};
94 std::int64_t avg_task_duration_ms{0};
95 std::int64_t max_task_duration_ms{0};
96 std::int64_t input_bytes_fetched{0};
97 std::int64_t output_bytes_uploaded{0};
98 int seconds_since_hb{0};
99};
100
101}
102
103#endif