41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using System.Diagnostics.Metrics;
|
|
|
|
namespace StellaOps.Graph.Api.Services;
|
|
|
|
public interface IGraphMetrics : IDisposable
|
|
{
|
|
Counter<long> BudgetDenied { get; }
|
|
Histogram<double> QueryLatencySeconds { get; }
|
|
Counter<long> OverlayCacheHit { get; }
|
|
Counter<long> OverlayCacheMiss { get; }
|
|
Histogram<double> ExportLatencySeconds { get; }
|
|
Meter Meter { get; }
|
|
}
|
|
|
|
public sealed class GraphMetrics : IGraphMetrics
|
|
{
|
|
private readonly Meter _meter;
|
|
|
|
public GraphMetrics()
|
|
{
|
|
_meter = new Meter("StellaOps.Graph.Api", "1.0.0");
|
|
BudgetDenied = _meter.CreateCounter<long>("graph_query_budget_denied_total");
|
|
QueryLatencySeconds = _meter.CreateHistogram<double>("graph_tile_latency_seconds", unit: "s");
|
|
OverlayCacheHit = _meter.CreateCounter<long>("graph_overlay_cache_hits_total");
|
|
OverlayCacheMiss = _meter.CreateCounter<long>("graph_overlay_cache_misses_total");
|
|
ExportLatencySeconds = _meter.CreateHistogram<double>("graph_export_latency_seconds", unit: "s");
|
|
}
|
|
|
|
public Counter<long> BudgetDenied { get; }
|
|
public Histogram<double> QueryLatencySeconds { get; }
|
|
public Counter<long> OverlayCacheHit { get; }
|
|
public Counter<long> OverlayCacheMiss { get; }
|
|
public Histogram<double> ExportLatencySeconds { get; }
|
|
public Meter Meter => _meter;
|
|
|
|
public void Dispose()
|
|
{
|
|
_meter.Dispose();
|
|
}
|
|
}
|