ORE Studio 0.0.4
Loading...
Searching...
No Matches
telemetry_entity.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_REPOSITORY_TELEMETRY_ENTITY_HPP
21#define ORES_TELEMETRY_REPOSITORY_TELEMETRY_ENTITY_HPP
22
23#include <string>
24#include <cstdint>
25#include <iosfwd>
26#include "sqlgen/Timestamp.hpp"
27#include "sqlgen/PrimaryKey.hpp"
28
29namespace ores::telemetry::database::repository {
30
38 constexpr static const char* schema = "public";
39 constexpr static const char* tablename = "ores_telemetry_logs_tbl";
40
44 sqlgen::PrimaryKey<std::string> id;
45
49 std::string tenant_id;
50
56 sqlgen::PrimaryKey<sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S">> timestamp;
57
61 std::string source;
62
66 std::string source_name;
67
71 std::optional<std::string> session_id;
72
76 std::optional<std::string> account_id;
77
81 std::string level;
82
86 std::string component;
87
91 std::string message;
92
96 std::string tag;
97
101 sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S"> recorded_at;
102};
103
104std::ostream& operator<<(std::ostream& s, const telemetry_entity& v);
105
110 constexpr static const char* schema = "public";
111 constexpr static const char* tablename = "ores_telemetry_stats_hourly_vw";
112
113 std::string hour;
114 std::string source;
115 std::string source_name;
116 std::string level;
117 std::int64_t log_count = 0;
118 std::int64_t unique_sessions = 0;
119 std::int64_t unique_accounts = 0;
120};
121
122std::ostream& operator<<(std::ostream& s, const telemetry_stats_hourly_entity& v);
123
128 constexpr static const char* schema = "public";
129 constexpr static const char* tablename = "ores_telemetry_stats_daily_vw";
130
131 std::string day;
132 std::string source;
133 std::string source_name;
134 std::string component;
135 std::string level;
136 std::int64_t log_count = 0;
137 std::int64_t unique_sessions = 0;
138 std::int64_t unique_accounts = 0;
139};
140
141std::ostream& operator<<(std::ostream& s, const telemetry_stats_daily_entity& v);
142
149 constexpr static const char* schema = "public";
150 constexpr static const char* tablename = "ores_telemetry_nats_server_samples_tbl";
151
152 sqlgen::PrimaryKey<sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S">> sampled_at;
153 sqlgen::PrimaryKey<std::string> tenant_id;
154 std::int64_t in_msgs{0};
155 std::int64_t out_msgs{0};
156 std::int64_t in_bytes{0};
157 std::int64_t out_bytes{0};
158 int connections{0};
159 std::int64_t mem_bytes{0};
160 int slow_consumers{0};
161};
162
169 constexpr static const char* schema = "public";
170 constexpr static const char* tablename = "ores_telemetry_service_samples_tbl";
171
172 sqlgen::PrimaryKey<sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S">> sampled_at;
173 sqlgen::PrimaryKey<std::string> service_name;
174 sqlgen::PrimaryKey<std::string> instance_id;
175 std::string version;
176};
177
184 constexpr static const char* schema = "public";
185 constexpr static const char* tablename = "ores_telemetry_nats_stream_samples_tbl";
186
187 sqlgen::PrimaryKey<sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S">> sampled_at;
188 sqlgen::PrimaryKey<std::string> tenant_id;
189 sqlgen::PrimaryKey<std::string> stream_name;
190 std::int64_t messages{0};
191 std::int64_t bytes{0};
192 int consumer_count{0};
193};
194
195}
196
197#endif
Represents a telemetry log record in the database.
Definition telemetry_entity.hpp:37
std::string source
Source type ('client' or 'server').
Definition telemetry_entity.hpp:61
std::string level
Log severity level.
Definition telemetry_entity.hpp:81
std::optional< std::string > account_id
Account ID (nullopt for no account).
Definition telemetry_entity.hpp:76
std::optional< std::string > session_id
Session ID (nullopt for no session).
Definition telemetry_entity.hpp:71
std::string message
Log message body.
Definition telemetry_entity.hpp:91
sqlgen::PrimaryKey< std::string > id
Log entry UUID - part of composite primary key.
Definition telemetry_entity.hpp:44
sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S"> recorded_at
Server receipt timestamp.
Definition telemetry_entity.hpp:101
sqlgen::PrimaryKey< sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S"> > timestamp
Log timestamp - part of composite primary key.
Definition telemetry_entity.hpp:56
std::string component
Logger/component name.
Definition telemetry_entity.hpp:86
std::string source_name
Source application name.
Definition telemetry_entity.hpp:66
std::string tag
Optional tag for filtering.
Definition telemetry_entity.hpp:96
std::string tenant_id
Tenant ID for multi-tenancy isolation.
Definition telemetry_entity.hpp:49
Entity for hourly telemetry statistics from continuous aggregates.
Definition telemetry_entity.hpp:109
Entity for daily telemetry statistics from continuous aggregates.
Definition telemetry_entity.hpp:127
Entity for a NATS server-level metrics sample.
Definition telemetry_entity.hpp:148
Entity for a single service heartbeat sample.
Definition telemetry_entity.hpp:168
Entity for a single JetStream stream metrics sample.
Definition telemetry_entity.hpp:183