ORE Studio 0.0.4
Loading...
Searching...
No Matches
telemetry_message_handler.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 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_TELEMETRY_MESSAGING_TELEMETRY_MESSAGE_HANDLER_HPP
21#define ORES_TELEMETRY_MESSAGING_TELEMETRY_MESSAGE_HANDLER_HPP
22
23#include <memory>
24#include "ores.comms/messaging/message_handler.hpp"
25#include "ores.comms/service/auth_session_service.hpp"
26#include "ores.logging/make_logger.hpp"
27#include "ores.database/domain/context.hpp"
28#include "ores.telemetry/repository/telemetry_repository.hpp"
29
31
46private:
47 inline static std::string_view logger_name =
48 "ores.telemetry.messaging.telemetry_message_handler";
49
50 static auto& lg() {
51 using namespace ores::logging;
52 static auto instance = make_logger(logger_name);
53 return instance;
54 }
55
56public:
64 std::shared_ptr<comms::service::auth_session_service> sessions);
65
74 boost::asio::awaitable<std::expected<std::vector<std::byte>, ores::utility::serialization::error_code>>
75 handle_message(comms::messaging::message_type type,
76 std::span<const std::byte> payload,
77 const std::string& remote_address) override;
78
79private:
91 boost::asio::awaitable<std::expected<std::vector<std::byte>, ores::utility::serialization::error_code>>
92 handle_submit_log_records_request(std::span<const std::byte> payload,
93 const std::string& remote_address);
94
104 boost::asio::awaitable<std::expected<std::vector<std::byte>, ores::utility::serialization::error_code>>
105 handle_get_telemetry_logs_request(std::span<const std::byte> payload);
106
116 boost::asio::awaitable<std::expected<std::vector<std::byte>, ores::utility::serialization::error_code>>
117 handle_get_telemetry_stats_request(std::span<const std::byte> payload);
118
122 static std::string severity_to_string(logging::severity_level level);
123
125 std::shared_ptr<comms::service::auth_session_service> sessions_;
127};
128
129}
130
131#endif
Network messaging protocol for log records.
Definition telemetry_message_handler.cpp:27
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
severity_level
Log severity levels following OpenTelemetry conventions.
Definition severity_level.hpp:34
Abstract interface for handling messages from a subsystem.
Definition message_handler.hpp:66
Context for the operations on a postgres database.
Definition context.hpp:30
Message handler for telemetry subsystem messages.
Definition telemetry_message_handler.hpp:45
boost::asio::awaitable< std::expected< std::vector< std::byte >, ores::utility::serialization::error_code > > handle_message(comms::messaging::message_type type, std::span< const std::byte > payload, const std::string &remote_address) override
Handle a telemetry subsystem message.
Definition telemetry_message_handler.cpp:39
Repository for telemetry log persistence and querying.
Definition telemetry_repository.hpp:43