Count WebSocket upgrades as successful calls and tidy the report (refs #95)
ci / test (postgres) (pull_request) Successful in 9m14s
ci / test (sqlite) (push) Successful in 4m11s
ci / test (sqlite) (pull_request) Successful in 4m12s
ci / test (postgres) (push) Successful in 9m40s
ci / image (pull_request) Successful in 2m14s
ci / image (push) Successful in 54s
ci / test (postgres) (pull_request) Successful in 9m14s
ci / test (sqlite) (push) Successful in 4m11s
ci / test (sqlite) (pull_request) Successful in 4m12s
ci / test (postgres) (push) Successful in 9m40s
ci / image (pull_request) Successful in 2m14s
ci / image (push) Successful in 54s
Trying the packaged release showed three things to fix: a 101 answer that opens a WebSocket was counted as a failure, the duration buckets were too coarse around the usual 200-500 ms of the brokers, and the report mixed CRLF and LF lines and named SQLite only by its version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6e365673b8
commit
9cf386d08b
4 files changed
+10
-7
No files matched your search
@@ -49,7 +49,7 @@ internal static class DiagnosticsExport
|
||||
new("Piattaforma", config.Platform.ToString().ToLowerInvariant()),
|
||||
new("Database", config.Db?.Describe() ?? "non configurato"),
|
||||
new("Cartella dei dati", config.Data.Root),
|
||||
new("Rete consentita", config.AllowNetwork ? "sì" : "no"),
|
||||
new("Raggiungibile da altri computer", config.AllowNetwork ? "sì" : "no"),
|
||||
new("Ordini reali consentiti", config.AllowLive ? "sì" : "no"),
|
||||
};
|
||||
var variables = environment
|
||||
|
||||
@@ -55,7 +55,7 @@ public static partial class DiagnosticsReporter
|
||||
var data = await db.ReadAsync(async s =>
|
||||
{
|
||||
(string Name, object? Value)[] window = [("from", request.From), ("to", request.To)];
|
||||
var engine = await s.FirstOrDefaultAsync(s.Engine == DbEngine.Sqlite ? "SELECT sqlite_version() AS v" : "SELECT version() AS v", r => r.Text("v")).ConfigureAwait(false);
|
||||
var engine = await s.FirstOrDefaultAsync(s.Engine == DbEngine.Sqlite ? "SELECT 'SQLite ' || sqlite_version() AS v" : "SELECT version() AS v", r => r.Text("v")).ConfigureAwait(false);
|
||||
var samples = await s.QueryAsync("SELECT * FROM diagnostic_samples WHERE taken_at >= @from AND taken_at <= @to ORDER BY taken_at", ReadSample, window).ConfigureAwait(false);
|
||||
var runs = await s.QueryAsync("SELECT job, due_at, started_at, finished_at, outcome, missed, error FROM job_runs WHERE started_at >= @from AND started_at <= @to",
|
||||
r => new Run(r.Text("job"), r.Moment("due_at"), r.Moment("started_at"), r.Moment("finished_at"), r.Text("outcome"), r.Bool("missed"), r.TextOrNull("error")), window)
|
||||
@@ -96,7 +96,7 @@ public static partial class DiagnosticsReporter
|
||||
text.AppendLine().Append(section);
|
||||
}
|
||||
|
||||
return Fit(Mask(text.ToString()));
|
||||
return Fit(Mask(text.ToString().ReplaceLineEndings("\n")));
|
||||
}
|
||||
|
||||
/// <summary>The user's folders and name out, the secrets out, and no more than <see cref="MaxBytes"/>.</summary>
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Anubis.Diagnostics;
|
||||
public sealed record HttpCallStats(string Host, long Calls, long Failures, IReadOnlyDictionary<string, long> Outcomes, long[] Buckets, double MaxMs, double TotalMs)
|
||||
{
|
||||
/// <summary>Upper bounds in milliseconds of the duration buckets; one more bucket holds everything slower.</summary>
|
||||
public static IReadOnlyList<double> Bounds { get; } = [5, 10, 20, 50, 100, 200, 300, 500, 750, 1000, 1500, 2000, 3000, 5000, 10000, 20000, 30000, 60000];
|
||||
public static IReadOnlyList<double> Bounds { get; } = [5, 10, 20, 30, 50, 75, 100, 150, 200, 250, 300, 400, 500, 750, 1000, 1500, 2000, 3000, 5000, 10000, 20000, 30000, 60000];
|
||||
|
||||
public double AverageMs => Calls == 0 ? 0 : TotalMs / Calls;
|
||||
|
||||
@@ -152,7 +152,8 @@ public sealed class HttpCallMeter : IDisposable
|
||||
|
||||
var key = (host ?? "?") + (port is { } p and not (80 or 443) ? ":" + p.ToString(CultureInfo.InvariantCulture) : "");
|
||||
var outcome = status?.ToString(CultureInfo.InvariantCulture) ?? error ?? "?";
|
||||
var failed = status is not (>= 200 and < 400);
|
||||
// 101 is the answer that opens a WebSocket: a success like 2xx and 3xx.
|
||||
var failed = status is not (>= 100 and < 400);
|
||||
var milliseconds = Math.Max(0, seconds * 1000);
|
||||
lock (_gate)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ public sealed class DiagnosticsTests
|
||||
using var source = new Meter(HttpCallMeter.MeterName);
|
||||
var duration = source.CreateHistogram<double>(HttpCallMeter.InstrumentName, "s");
|
||||
const string host = "misura.invalid";
|
||||
foreach (var (seconds, status) in new[] { (0.04, 200), (0.08, 200), (0.4, 200), (2.5, 503) })
|
||||
foreach (var (seconds, status) in new[] { (0.04, 200), (0.08, 101), (0.4, 200), (2.5, 503) })
|
||||
{
|
||||
duration.Record(seconds, new("server.address", host), new("server.port", 443), new("http.response.status_code", status));
|
||||
}
|
||||
@@ -35,10 +35,12 @@ public sealed class DiagnosticsTests
|
||||
var main = calls[host];
|
||||
Assert.AreEqual(4, main.Calls);
|
||||
Assert.AreEqual(1, main.Failures);
|
||||
Assert.AreEqual(3, main.Outcomes["200"]);
|
||||
Assert.AreEqual(2, main.Outcomes["200"]);
|
||||
Assert.AreEqual(1, main.Outcomes["101"], "A WebSocket that opens is not a failure.");
|
||||
Assert.AreEqual(1, main.Outcomes["503"]);
|
||||
Assert.AreEqual(2500, main.MaxMs);
|
||||
Assert.AreEqual(100, main.Percentile(0.5), "The second fastest call is under the 100 ms bound.");
|
||||
Assert.AreEqual(400, main.Percentile(0.75));
|
||||
Assert.AreEqual(2500, main.Percentile(0.95), "Never more than the slowest call.");
|
||||
Assert.AreEqual(1, calls[host + ":8443"].Failures);
|
||||
Assert.AreEqual(1, calls[host + ":8443"].Outcomes["timeout"]);
|
||||
|
||||
Reference in new issue
Block a user