|
ORE Studio 0.0.4
|
Repository for telemetry log persistence and querying. More...
#include <telemetry_repository.hpp>

Public Types | |
| using | context = ores::database::context |
Public Member Functions | |
| std::string | sql () |
| Returns the SQL created by sqlgen to construct the table. | |
| void | create (context ctx, const domain::telemetry_log_entry &entry) |
| Creates a single log entry. | |
| std::size_t | create_batch (context ctx, const domain::telemetry_batch &batch) |
| Creates multiple log entries in a batch. | |
| std::vector< domain::telemetry_log_entry > | query (context ctx, const domain::telemetry_query &q) |
| Queries log entries with filters. | |
| std::uint64_t | count (context ctx, const domain::telemetry_query &q) |
| Counts log entries matching a query. | |
| std::vector< domain::telemetry_log_entry > | read_by_session (context ctx, const boost::uuids::uuid &session_id, std::uint32_t limit=1000) |
| Reads logs for a specific session. | |
| std::vector< domain::telemetry_log_entry > | read_by_account (context ctx, const boost::uuids::uuid &account_id, const std::chrono::system_clock::time_point &start, const std::chrono::system_clock::time_point &end, std::uint32_t limit=1000) |
| Reads logs for a specific account. | |
| std::vector< domain::telemetry_stats > | read_hourly_stats (context ctx, const domain::telemetry_stats_query &q) |
| Reads hourly statistics. | |
| std::vector< domain::telemetry_stats > | read_daily_stats (context ctx, const domain::telemetry_stats_query &q) |
| Reads daily statistics. | |
| domain::telemetry_summary | get_summary (context ctx, std::uint32_t hours=24) |
| Gets a summary of telemetry activity. | |
| std::uint64_t | count_errors (context ctx, const std::string &source_name, std::uint32_t hours=1) |
| Counts error logs in the last N hours for a source. | |
| std::uint64_t | delete_old_logs (context ctx, const std::chrono::system_clock::time_point &older_than) |
| Deletes logs older than the specified retention period. | |
| void | insert_server_sample (context ctx, const domain::nats_server_sample &sample) |
| Inserts a single NATS server-level metrics sample. | |
| void | insert_stream_samples (context ctx, const std::vector< domain::nats_stream_sample > &samples) |
| Inserts a batch of NATS per-stream metrics samples. | |
| std::vector< domain::nats_server_sample > | query_server_samples (context ctx, const domain::nats_server_samples_query &q) |
| Queries NATS server samples within a time range. | |
| std::vector< domain::nats_stream_sample > | query_stream_samples (context ctx, const domain::nats_stream_samples_query &q) |
| Queries NATS stream samples within a time range. | |
| void | insert_service_sample (context ctx, const domain::service_sample &sample) |
| Inserts a single service heartbeat sample. | |
| std::vector< domain::service_sample > | list_service_samples (context ctx) |
| Returns the latest heartbeat per (service_name, instance_id). | |
Repository for telemetry log persistence and querying.
Handles CRUD operations for telemetry log records stored in a TimescaleDB hypertable. Supports time-range queries and statistics aggregation.
| std::size_t create_batch | ( | context | ctx, |
| const domain::telemetry_batch & | batch | ||
| ) |
Creates multiple log entries in a batch.
More efficient than individual inserts for bulk operations.
| std::uint64_t count | ( | context | ctx, |
| const domain::telemetry_query & | q | ||
| ) |
Counts log entries matching a query.
Useful for pagination.

| std::vector< domain::telemetry_log_entry > read_by_session | ( | context | ctx, |
| const boost::uuids::uuid & | session_id, | ||
| std::uint32_t | limit = 1000 |
||
| ) |
Reads logs for a specific session.
| ctx | The database context |
| session_id | The session UUID |
| limit | Maximum number of logs to return |
| std::vector< domain::telemetry_log_entry > read_by_account | ( | context | ctx, |
| const boost::uuids::uuid & | account_id, | ||
| const std::chrono::system_clock::time_point & | start, | ||
| const std::chrono::system_clock::time_point & | end, | ||
| std::uint32_t | limit = 1000 |
||
| ) |
Reads logs for a specific account.
| ctx | The database context |
| account_id | The account UUID |
| start | Start of time range |
| end | End of time range |
| limit | Maximum number of logs to return |
| domain::telemetry_summary get_summary | ( | context | ctx, |
| std::uint32_t | hours = 24 |
||
| ) |
Gets a summary of telemetry activity.
| ctx | The database context |
| hours | Number of hours to include (default: 24) |
| std::uint64_t count_errors | ( | context | ctx, |
| const std::string & | source_name, | ||
| std::uint32_t | hours = 1 |
||
| ) |
Counts error logs in the last N hours for a source.
Useful for monitoring and alerting.
| ctx | The database context |
| std::uint64_t delete_old_logs | ( | context | ctx, |
| const std::chrono::system_clock::time_point & | older_than | ||
| ) |
Deletes logs older than the specified retention period.
Note: With TimescaleDB, this is typically handled by retention policies. This method is for manual cleanup or non-TimescaleDB deployments.
| ctx | The database context |
| older_than | Delete logs older than this timestamp |
| void insert_service_sample | ( | context | ctx, |
| const domain::service_sample & | sample | ||
| ) |
Inserts a single service heartbeat sample.
Called by the telemetry service each time it receives a heartbeat publish from a domain service.
| std::vector< domain::service_sample > list_service_samples | ( | context | ctx | ) |
Returns the latest heartbeat per (service_name, instance_id).
Used by the service dashboard to determine which services are currently running and when they were last seen.