feat(core): add metrics history storage interface and point model

This commit is contained in:
dualfroz committed 2026-08-25 14:24:24 +02:00
1 parent 3a913c4375
commit 7dd006c479
3 files changed
+46

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
using Vantage.Core.Models;
namespace Vantage.Core.History;
public interface IMetricsStore
{
Task RecordAsync(MetricSample sample, CancellationToken cancellationToken = default);
Task RecordManyAsync(IEnumerable<MetricSample> samples, CancellationToken cancellationToken = default);
Task RecordHostMetricsAsync(string hostId, HostMetrics metrics, CancellationToken cancellationToken = default);
Task<IReadOnlyList<MetricPoint>> QueryAsync(
string hostId,
string metric,
DateTimeOffset from,
DateTimeOffset to,
CancellationToken cancellationToken = default);
Task<int> PruneOlderThanAsync(DateTimeOffset cutoff, CancellationToken cancellationToken = default);
Task<long> CountAsync(CancellationToken cancellationToken = default);
}
+18
View File
@@ -0,0 +1,18 @@
namespace Vantage.Core.History;
public static class MetricNames
{
public const string Cpu = "cpu";
public const string Memory = "memory";
public const string Disk = "disk";
public const string Load1 = "load1";
public const string Load5 = "load5";
public const string Load15 = "load15";
public const string NetworkRx = "networkRx";
public const string NetworkTx = "networkTx";
public static readonly IReadOnlyList<string> All = new[]
{
Cpu, Memory, Disk, Load1, Load5, Load15, NetworkRx, NetworkTx
};
}
+5
View File
@@ -0,0 +1,5 @@
namespace Vantage.Core.History;
public readonly record struct MetricPoint(DateTimeOffset Timestamp, double Value);
public readonly record struct MetricSample(string HostId, string Metric, DateTimeOffset Timestamp, double Value);