Rename Feedser to Concelier
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
namespace StellaOps.Concelier.WebService.Diagnostics;
|
||||
|
||||
internal sealed record StorageBootstrapHealth(
|
||||
string Driver,
|
||||
bool Completed,
|
||||
DateTimeOffset? CompletedAt,
|
||||
double? DurationMs);
|
||||
|
||||
internal sealed record TelemetryHealth(
|
||||
bool Enabled,
|
||||
bool Tracing,
|
||||
bool Metrics,
|
||||
bool Logging);
|
||||
|
||||
internal sealed record HealthDocument(
|
||||
string Status,
|
||||
DateTimeOffset StartedAt,
|
||||
double UptimeSeconds,
|
||||
StorageBootstrapHealth Storage,
|
||||
TelemetryHealth Telemetry);
|
||||
|
||||
internal sealed record MongoReadyHealth(
|
||||
string Status,
|
||||
double? LatencyMs,
|
||||
DateTimeOffset? CheckedAt,
|
||||
string? Error);
|
||||
|
||||
internal sealed record ReadyDocument(
|
||||
string Status,
|
||||
DateTimeOffset StartedAt,
|
||||
double UptimeSeconds,
|
||||
MongoReadyHealth Mongo);
|
||||
25
src/StellaOps.Concelier.WebService/Diagnostics/JobMetrics.cs
Normal file
25
src/StellaOps.Concelier.WebService/Diagnostics/JobMetrics.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Diagnostics.Metrics;
|
||||
|
||||
namespace StellaOps.Concelier.WebService.Diagnostics;
|
||||
|
||||
internal static class JobMetrics
|
||||
{
|
||||
internal const string MeterName = "StellaOps.Concelier.WebService.Jobs";
|
||||
|
||||
private static readonly Meter Meter = new(MeterName);
|
||||
|
||||
internal static readonly Counter<long> TriggerCounter = Meter.CreateCounter<long>(
|
||||
"web.jobs.triggered",
|
||||
unit: "count",
|
||||
description: "Number of job trigger requests accepted by the web service.");
|
||||
|
||||
internal static readonly Counter<long> TriggerConflictCounter = Meter.CreateCounter<long>(
|
||||
"web.jobs.trigger.conflict",
|
||||
unit: "count",
|
||||
description: "Number of job trigger requests that resulted in conflicts or rejections.");
|
||||
|
||||
internal static readonly Counter<long> TriggerFailureCounter = Meter.CreateCounter<long>(
|
||||
"web.jobs.trigger.failed",
|
||||
unit: "count",
|
||||
description: "Number of job trigger requests that failed at runtime.");
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace StellaOps.Concelier.WebService.Diagnostics;
|
||||
|
||||
internal static class ProblemTypes
|
||||
{
|
||||
public const string NotFound = "https://stellaops.org/problems/not-found";
|
||||
public const string Validation = "https://stellaops.org/problems/validation";
|
||||
public const string Conflict = "https://stellaops.org/problems/conflict";
|
||||
public const string Locked = "https://stellaops.org/problems/locked";
|
||||
public const string LeaseRejected = "https://stellaops.org/problems/lease-rejected";
|
||||
public const string JobFailure = "https://stellaops.org/problems/job-failure";
|
||||
public const string ServiceUnavailable = "https://stellaops.org/problems/service-unavailable";
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace StellaOps.Concelier.WebService.Diagnostics;
|
||||
|
||||
internal sealed class ServiceStatus
|
||||
{
|
||||
private readonly TimeProvider _timeProvider;
|
||||
private readonly DateTimeOffset _startedAt;
|
||||
private readonly object _sync = new();
|
||||
|
||||
private DateTimeOffset? _bootstrapCompletedAt;
|
||||
private TimeSpan? _bootstrapDuration;
|
||||
private DateTimeOffset? _lastReadyCheckAt;
|
||||
private TimeSpan? _lastMongoLatency;
|
||||
private string? _lastMongoError;
|
||||
private bool _lastReadySucceeded;
|
||||
|
||||
public ServiceStatus(TimeProvider timeProvider)
|
||||
{
|
||||
_timeProvider = timeProvider ?? TimeProvider.System;
|
||||
_startedAt = _timeProvider.GetUtcNow();
|
||||
}
|
||||
|
||||
public ServiceHealthSnapshot CreateSnapshot()
|
||||
{
|
||||
lock (_sync)
|
||||
{
|
||||
return new ServiceHealthSnapshot(
|
||||
CapturedAt: _timeProvider.GetUtcNow(),
|
||||
StartedAt: _startedAt,
|
||||
BootstrapCompletedAt: _bootstrapCompletedAt,
|
||||
BootstrapDuration: _bootstrapDuration,
|
||||
LastReadyCheckAt: _lastReadyCheckAt,
|
||||
LastMongoLatency: _lastMongoLatency,
|
||||
LastMongoError: _lastMongoError,
|
||||
LastReadySucceeded: _lastReadySucceeded);
|
||||
}
|
||||
}
|
||||
|
||||
public void MarkBootstrapCompleted(TimeSpan duration)
|
||||
{
|
||||
lock (_sync)
|
||||
{
|
||||
var completedAt = _timeProvider.GetUtcNow();
|
||||
_bootstrapCompletedAt = completedAt;
|
||||
_bootstrapDuration = duration;
|
||||
_lastReadySucceeded = true;
|
||||
_lastMongoLatency = duration;
|
||||
_lastMongoError = null;
|
||||
_lastReadyCheckAt = completedAt;
|
||||
}
|
||||
}
|
||||
|
||||
public void RecordMongoCheck(bool success, TimeSpan latency, string? error)
|
||||
{
|
||||
lock (_sync)
|
||||
{
|
||||
_lastReadySucceeded = success;
|
||||
_lastMongoLatency = latency;
|
||||
_lastMongoError = success ? null : error;
|
||||
_lastReadyCheckAt = _timeProvider.GetUtcNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed record ServiceHealthSnapshot(
|
||||
DateTimeOffset CapturedAt,
|
||||
DateTimeOffset StartedAt,
|
||||
DateTimeOffset? BootstrapCompletedAt,
|
||||
TimeSpan? BootstrapDuration,
|
||||
DateTimeOffset? LastReadyCheckAt,
|
||||
TimeSpan? LastMongoLatency,
|
||||
string? LastMongoError,
|
||||
bool LastReadySucceeded);
|
||||
Reference in New Issue
Block a user