Rapporto di diagnostica della raccolta (#39)
Dopo una prova dal vivo andata male, Alberto deve poter mandare un solo file che spieghi perché, senza che nessuno veda dati di altre persone. Attività ha ora il pulsante «Diagnostica», che scarica il rapporto delle sessioni degli ultimi 14 giorni: pagine aperte e forma degli indirizzi, risposte per tipo, stato e dimensione con ciò che i lettori ne hanno fatto, struttura stretta delle forme sconosciute, ricette, segnali, permessi negati, file in coda e scaricati, e il motivo di ogni arresto. Nel rapporto entrano solo valori da elenchi chiusi, numeri, orari e forme: mai nomi, indirizzi completi, codici, cursori, cookie o pezzi di risposte. Le forme degli indirizzi e la regola delle chiavi-dato passano dalla sonda a Core, e la sonda le richiama. Il registratore non lancia mai eccezioni verso la raccolta e tiene i file in Dati/diagnostica per 14 giorni. Prova che il rapporto non contiene valori, con controlli di mutazione; tre giri di revisione avversaria (25 difetti confermati, tutti corretti). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bf03cb45a5
commit
badd1681a0
55 files changed
+5395
-134
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,212 @@
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Febe.Core.Abstractions;
|
||||
using Febe.Core.Domain;
|
||||
|
||||
namespace Febe.Core.Collection.Diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// What <see cref="DiagnosticLog.ReadAll"/> found: the traces, oldest first, how many lines were damaged, and how many
|
||||
/// day files could not be opened or read at all (held by another program, a read error of the disk, no permission).
|
||||
/// </summary>
|
||||
public sealed record DiagnosticLogContents(IReadOnlyList<SessionTrace> Traces, int DamagedLines, int UnreadableFiles = 0);
|
||||
|
||||
/// <summary>
|
||||
/// The finished traces of the diagnostic report (issue #39), one JSON line each, in
|
||||
/// <c>Dati/diagnostica/sessioni-AAAA-MM-GG.jsonl</c> by local day of the start of the trace. Kept
|
||||
/// <see cref="DefaultDays"/> days: older files of its own folder (and only those, by their name) are deleted when a
|
||||
/// line is written or the log is read. Each line is written whole and flushed; a damaged line (a stop in the middle
|
||||
/// of a write) is skipped and counted when reading, and so is a file that cannot be read. A session in progress also
|
||||
/// has lines of its own (its start, then checkpoints): when reading, a trace found more than once (same session and
|
||||
/// start) is kept once, the finished line over the ones in progress, else the last one. Thread-safe.
|
||||
/// </summary>
|
||||
public sealed class DiagnosticLog
|
||||
{
|
||||
/// <summary>Days kept, today included.</summary>
|
||||
public const int DefaultDays = 14;
|
||||
|
||||
private const string Prefix = "sessioni-";
|
||||
private const string Extension = ".jsonl";
|
||||
private const string DayFormat = "yyyy-MM-dd";
|
||||
|
||||
private readonly IClock _clock;
|
||||
private readonly Lock _gate = new();
|
||||
private DateOnly? _retentionDay;
|
||||
|
||||
public DiagnosticLog(string folder, IClock clock, int days = DefaultDays)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(folder);
|
||||
ArgumentOutOfRangeException.ThrowIfLessThan(days, 1);
|
||||
Folder = Path.GetFullPath(folder);
|
||||
_clock = clock ?? throw new ArgumentNullException(nameof(clock));
|
||||
Days = days;
|
||||
}
|
||||
|
||||
public string Folder { get; }
|
||||
|
||||
public int Days { get; }
|
||||
|
||||
/// <summary>Name of the file of a local day.</summary>
|
||||
public static string FileNameFor(DateOnly day) => Prefix + day.ToString(DayFormat, CultureInfo.InvariantCulture) + Extension;
|
||||
|
||||
/// <summary>Appends one finished trace to the file of the local day of its start.</summary>
|
||||
public void Append(SessionTrace trace)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(trace);
|
||||
var line = JsonSerializer.Serialize(trace, DiagnosticsJsonContext.Default.SessionTrace);
|
||||
var bytes = Encoding.UTF8.GetBytes(line + "\n");
|
||||
var day = LocalCalendar.Today(trace.Start, _clock.LocalZone);
|
||||
lock (_gate)
|
||||
{
|
||||
Directory.CreateDirectory(Folder);
|
||||
ApplyRetention(force: false);
|
||||
using var stream = new FileStream(Path.Combine(Folder, FileNameFor(day)), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
|
||||
if (stream.Length > 0)
|
||||
{
|
||||
// A stop in the middle of a write leaves a line without its end: start on a new line, so that only
|
||||
// the damaged line is lost and not this one too.
|
||||
stream.Seek(-1, SeekOrigin.End);
|
||||
if (stream.ReadByte() != '\n')
|
||||
{
|
||||
stream.WriteByte((byte)'\n');
|
||||
}
|
||||
}
|
||||
|
||||
stream.Seek(0, SeekOrigin.End);
|
||||
stream.Write(bytes);
|
||||
stream.Flush(flushToDisk: true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>True when a trace that started at <paramref name="start"/> is among the days kept.</summary>
|
||||
public bool Keeps(DateTimeOffset start) => LocalCalendar.Today(start, _clock.LocalZone) >= FirstDayKept();
|
||||
|
||||
/// <summary>
|
||||
/// Every trace of the days kept, oldest first, once each (see the class); damaged lines and unreadable files are
|
||||
/// skipped and counted.
|
||||
/// </summary>
|
||||
public DiagnosticLogContents ReadAll()
|
||||
{
|
||||
var traces = new List<SessionTrace>();
|
||||
var damaged = 0;
|
||||
var unreadable = 0;
|
||||
lock (_gate)
|
||||
{
|
||||
if (!Directory.Exists(Folder))
|
||||
{
|
||||
return new DiagnosticLogContents([], 0);
|
||||
}
|
||||
|
||||
ApplyRetention(force: true);
|
||||
var first = FirstDayKept();
|
||||
foreach (var (day, path) in Files().Where(f => f.Day >= first).OrderBy(f => f.Day))
|
||||
{
|
||||
string[] lines;
|
||||
try
|
||||
{
|
||||
using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
using var reader = new StreamReader(stream, Encoding.UTF8);
|
||||
lines = reader.ReadToEnd().Split('\n');
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
// One file only: the others are still read, and the report says that one is missing.
|
||||
unreadable++;
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var raw in lines)
|
||||
{
|
||||
var line = raw.Trim();
|
||||
if (line.Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (JsonSerializer.Deserialize(line, DiagnosticsJsonContext.Default.SessionTrace) is { } trace)
|
||||
{
|
||||
traces.Add(trace);
|
||||
}
|
||||
else
|
||||
{
|
||||
damaged++;
|
||||
}
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
damaged++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new DiagnosticLogContents([.. Latest(traces).OrderBy(t => t.Start)], damaged, unreadable);
|
||||
}
|
||||
|
||||
/// <summary>One trace per session and start: the finished one if there is one, else the last line written.</summary>
|
||||
internal static IEnumerable<SessionTrace> Latest(IEnumerable<SessionTrace> inWriteOrder)
|
||||
{
|
||||
var kept = new Dictionary<(long?, DateTimeOffset), SessionTrace>();
|
||||
foreach (var trace in inWriteOrder)
|
||||
{
|
||||
var key = (trace.Session, trace.Start);
|
||||
if (!kept.TryGetValue(key, out var earlier) || !(trace.InProgress && !earlier.InProgress))
|
||||
{
|
||||
kept[key] = trace;
|
||||
}
|
||||
}
|
||||
|
||||
return kept.Values;
|
||||
}
|
||||
|
||||
private DateOnly FirstDayKept() => LocalCalendar.Today(_clock.Now, _clock.LocalZone).AddDays(-(Days - 1));
|
||||
|
||||
/// <summary>Deletes the files of days before the ones kept (once per day unless forced).</summary>
|
||||
private void ApplyRetention(bool force)
|
||||
{
|
||||
var today = LocalCalendar.Today(_clock.Now, _clock.LocalZone);
|
||||
if (!force && _retentionDay == today)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_retentionDay = today;
|
||||
var first = FirstDayKept();
|
||||
foreach (var (day, path) in Files())
|
||||
{
|
||||
if (day < first)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
// Tried again at the next write or reading.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The files of this log in the folder, by the day in their name (other files are never touched).</summary>
|
||||
private IEnumerable<(DateOnly Day, string Path)> Files()
|
||||
{
|
||||
if (!Directory.Exists(Folder))
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (var path in Directory.EnumerateFiles(Folder, Prefix + "*" + Extension))
|
||||
{
|
||||
var name = Path.GetFileName(path);
|
||||
var text = name[Prefix.Length..^Extension.Length];
|
||||
if (DateOnly.TryParseExact(text, DayFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out var day))
|
||||
{
|
||||
yield return (day, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using Febe.Core.Domain;
|
||||
|
||||
namespace Febe.Core.Collection.Diagnostics;
|
||||
|
||||
/// <summary>The head of an exported report.</summary>
|
||||
/// <param name="Version">Febe's version (three numbers).</param>
|
||||
/// <param name="Edition">«docker» or «windows».</param>
|
||||
/// <param name="Created">When the report is written.</param>
|
||||
/// <param name="Zone">Alberto's time zone: the times of the report are written in it.</param>
|
||||
/// <param name="Days">Days the log keeps.</param>
|
||||
/// <param name="DamagedLines">Lines of the log that could not be read («righeRovinate»).</param>
|
||||
/// <param name="RecorderFaults">Errors the recorder swallowed, failed writes among them («erroriRegistratore»).</param>
|
||||
/// <param name="UnreadableFiles">Day files of the log that could not be read («fileIlleggibili»).</param>
|
||||
/// <param name="UnfinishedSessions">Sessions Febe stopped without closing, a crash or a kill («sessioniSenzaFine»).</param>
|
||||
public sealed record DiagnosticReportHeader(
|
||||
string Version,
|
||||
string Edition,
|
||||
DateTimeOffset Created,
|
||||
TimeZoneInfo Zone,
|
||||
int Days = DiagnosticLog.DefaultDays,
|
||||
int DamagedLines = 0,
|
||||
int RecorderFaults = 0,
|
||||
int UnreadableFiles = 0,
|
||||
int UnfinishedSessions = 0);
|
||||
|
||||
/// <summary>
|
||||
/// The file Alberto sends after a live test that went wrong (issue #39, «Esporta il rapporto di diagnostica»):
|
||||
/// UTF-8 JSON without BOM, indented, with the traces of the engine sessions and of the days outside sessions. Like
|
||||
/// the traces, it holds no data value: no address, user name, cookie, body or free text.
|
||||
/// </summary>
|
||||
public static partial class DiagnosticReport
|
||||
{
|
||||
/// <summary>The value of «rapporto».</summary>
|
||||
public const string Title = "diagnostica della raccolta";
|
||||
|
||||
/// <summary>Name of the exported file for the local day of <paramref name="now"/>.</summary>
|
||||
public static string FileName(DateTimeOffset now, TimeZoneInfo zone) =>
|
||||
$"febe-diagnostica-{LocalCalendar.Today(now, zone).ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)}.json";
|
||||
|
||||
/// <summary>Writes the report to <paramref name="stream"/> (left open).</summary>
|
||||
/// <exception cref="InvalidOperationException">Debug builds only: the text holds «://» or «@», which no reduction lets through.</exception>
|
||||
public static void Write(Stream stream, IReadOnlyList<SessionTrace> traces, DiagnosticReportHeader header)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(stream);
|
||||
ArgumentNullException.ThrowIfNull(traces);
|
||||
ArgumentNullException.ThrowIfNull(header);
|
||||
var zone = header.Zone;
|
||||
using var buffer = new MemoryStream();
|
||||
using (var writer = new Utf8JsonWriter(buffer, new JsonWriterOptions { Indented = true }))
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
writer.WriteString("rapporto", Title);
|
||||
writer.WriteString("versione", Safe(header.Version));
|
||||
writer.WriteString("edizione", Safe(header.Edition));
|
||||
writer.WriteString("creato", Local(header.Created, zone));
|
||||
writer.WriteString("fuso", Safe(ZoneName(zone)));
|
||||
writer.WriteNumber("giorni", header.Days);
|
||||
|
||||
// Not zero: the report is not the whole story (lines of the log lost, writes or readings that failed, day
|
||||
// files that could not be read, sessions cut short by a crash).
|
||||
writer.WriteNumber("righeRovinate", Math.Max(0, header.DamagedLines));
|
||||
writer.WriteNumber("erroriRegistratore", Math.Max(0, header.RecorderFaults));
|
||||
writer.WriteNumber("fileIlleggibili", Math.Max(0, header.UnreadableFiles));
|
||||
writer.WriteNumber("sessioniSenzaFine", Math.Max(0, header.UnfinishedSessions));
|
||||
WriteTraces(writer, "sessioni", traces.Where(t => t.Session is not null), zone);
|
||||
WriteTraces(writer, "fuoriSessione", traces.Where(t => t.Session is null), zone);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
var text = Encoding.UTF8.GetString(buffer.GetBuffer(), 0, (int)buffer.Length);
|
||||
if (text.Contains("://", StringComparison.Ordinal) || text.Contains('@', StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException("Il rapporto di diagnostica contiene un indirizzo o un nome: una riduzione non ha funzionato.");
|
||||
}
|
||||
#endif
|
||||
|
||||
buffer.Position = 0;
|
||||
buffer.CopyTo(stream);
|
||||
stream.WriteByte((byte)'\n');
|
||||
}
|
||||
|
||||
private static void WriteTraces(Utf8JsonWriter writer, string name, IEnumerable<SessionTrace> traces, TimeZoneInfo zone)
|
||||
{
|
||||
writer.WriteStartArray(name);
|
||||
foreach (var trace in traces.OrderBy(t => t.Start))
|
||||
{
|
||||
JsonSerializer.Serialize(writer, InZone(trace, zone), DiagnosticsJsonContext.Default.SessionTrace);
|
||||
}
|
||||
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
|
||||
/// <summary>The same trace with its times written in Alberto's zone (same instants, local offset).</summary>
|
||||
private static SessionTrace InZone(SessionTrace trace, TimeZoneInfo zone) => trace with
|
||||
{
|
||||
Start = Local(trace.Start, zone),
|
||||
End = trace.End is { } end ? Local(end, zone) : null,
|
||||
Pages = [.. trace.Pages.Select(p => p with { At = Local(p.At, zone) })],
|
||||
Recipes = [.. trace.Recipes.Select(r => r with { At = Local(r.At, zone) })],
|
||||
Signals = [.. trace.Signals.Select(s => s with { At = Local(s.At, zone) })],
|
||||
};
|
||||
|
||||
private static DateTimeOffset Local(DateTimeOffset instant, TimeZoneInfo zone) => TimeZoneInfo.ConvertTime(instant, zone);
|
||||
|
||||
/// <summary>
|
||||
/// The IANA name of the zone («Europe/Rome»), also on Windows, whose own names have spaces («W. Europe Standard
|
||||
/// Time»), the one of the computer's region when the Windows name covers several («Europe/Rome» rather than
|
||||
/// «Europe/Berlin» in Italy); the Windows name with its spaces as underscores when there is no IANA one.
|
||||
/// </summary>
|
||||
internal static string ZoneName(TimeZoneInfo zone)
|
||||
{
|
||||
string? region = null;
|
||||
try
|
||||
{
|
||||
region = RegionInfo.CurrentRegion.TwoLetterISORegionName;
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
// No region (invariant culture): the zone's main IANA name.
|
||||
}
|
||||
|
||||
if (region is { Length: 2 } && TimeZoneInfo.TryConvertWindowsIdToIanaId(zone.Id, region, out var regional))
|
||||
{
|
||||
return regional;
|
||||
}
|
||||
|
||||
return TimeZoneInfo.TryConvertWindowsIdToIanaId(zone.Id, out var iana) ? iana : zone.Id.Replace(' ', '_');
|
||||
}
|
||||
|
||||
private static string Safe(string? text) => text is not null && SafeText().IsMatch(text) ? text : CollectionDiagnostics.Other;
|
||||
|
||||
[GeneratedRegex("^[A-Za-z0-9_./+-]{1,64}$", RegexOptions.CultureInvariant)]
|
||||
private static partial Regex SafeText();
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Febe.Core.Abstractions;
|
||||
using Febe.Core.Collection.Downloads;
|
||||
using Febe.Core.Collection.Recipes;
|
||||
using Febe.Core.Domain;
|
||||
using Febe.Core.Engine;
|
||||
|
||||
namespace Febe.Core.Collection.Diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// What one engine session did with the site, for the diagnostic report (issue #39), or what happened outside any
|
||||
/// session on one local day (<see cref="Session"/> null: Alberto at the browser, downloads between sessions).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// It holds no data value by construction: only enums, codes from closed lists (signal codes, page and target names
|
||||
/// of the site map), counts, sizes, times and address patterns where every segment that is not a word of the site
|
||||
/// is <c>{numero}</c> or <c>{testo}</c>. Never addresses, user names, bodies, cookies or free text.
|
||||
/// </remarks>
|
||||
public sealed record SessionTrace
|
||||
{
|
||||
/// <summary>The engine session; null for the bucket outside sessions.</summary>
|
||||
public long? Session { get; init; }
|
||||
|
||||
public DateTimeOffset Start { get; init; }
|
||||
|
||||
public DateTimeOffset? End { get; init; }
|
||||
|
||||
public SessionOutcome? Outcome { get; init; }
|
||||
|
||||
public SessionStopCause? StopCause { get; init; }
|
||||
|
||||
/// <summary>The recipe status that stopped the session early, when one did.</summary>
|
||||
public RecipeStatus? StoppedBy { get; init; }
|
||||
|
||||
/// <summary>The speed factor of the session (spec §7.7), two decimals.</summary>
|
||||
public double? Mood { get; init; }
|
||||
|
||||
/// <summary>True for a session still running when the trace was taken (or when Febe stopped).</summary>
|
||||
public bool InProgress { get; init; }
|
||||
|
||||
/// <summary>Pages the recipes opened, in order.</summary>
|
||||
public IReadOnlyList<PageVisit> Pages { get; init; } = [];
|
||||
|
||||
/// <summary>Main-frame navigations (also the ones the engine did not ask for), counted by pattern.</summary>
|
||||
public IReadOnlyList<NavigationGroup> Navigations { get; init; } = [];
|
||||
|
||||
/// <summary>Responses the page received, counted by kind, with sizes and what the readers did with them.</summary>
|
||||
public IReadOnlyList<ResponseGroup> Responses { get; init; } = [];
|
||||
|
||||
/// <summary>Distinct key structures of responses the readers did not recognize (strict: no key that could be data).</summary>
|
||||
public IReadOnlyList<UnknownShape> UnknownShapes { get; init; } = [];
|
||||
|
||||
/// <summary>Verdicts of the recipe steps: «riconosciuto», «vuoto», «sconosciuto».</summary>
|
||||
public IReadOnlyList<VerdictCount> Steps { get; init; } = [];
|
||||
|
||||
public IReadOnlyList<TargetCount> Targets { get; init; } = [];
|
||||
|
||||
public IReadOnlyList<RecipeLine> Recipes { get; init; } = [];
|
||||
|
||||
public IReadOnlyList<SignalLine> Signals { get; init; } = [];
|
||||
|
||||
/// <summary>Refusals of the Governor.</summary>
|
||||
public IReadOnlyList<DenialCount> Denials { get; init; } = [];
|
||||
|
||||
public IReadOnlyList<QueuedFiles> FilesQueued { get; init; } = [];
|
||||
|
||||
public IReadOnlyList<DownloadGroup> Downloads { get; init; } = [];
|
||||
|
||||
/// <summary>Bytes of the files downloaded (what crossed the network), when the queue said.</summary>
|
||||
public long DownloadedBytes { get; init; }
|
||||
|
||||
/// <summary>Items not kept because a list was full: counted, never dropped silently.</summary>
|
||||
public TraceOverflow Overflow { get; init; } = new();
|
||||
}
|
||||
|
||||
/// <summary>A page a recipe opened: the name in the site map and its shape, never the address.</summary>
|
||||
public sealed record PageVisit(DateTimeOffset At, string Page, string? Pattern, bool Ok);
|
||||
|
||||
/// <summary>Main-frame navigations with the same pattern.</summary>
|
||||
public sealed record NavigationGroup(HostKind HostKind, string? Page, string Pattern, bool SameDocument, int Count);
|
||||
|
||||
/// <summary>Responses with the same host kind, pattern, resource type, MIME type and status class.</summary>
|
||||
/// <param name="Count">Responses seen.</param>
|
||||
/// <param name="Bytes">Sum of what crossed the network.</param>
|
||||
/// <param name="MaxBytes">Largest single response.</param>
|
||||
/// <param name="Recognized">Bodies (or blocks of a page) the readers recognized.</param>
|
||||
/// <param name="Empty">Bodies with no contents (an empty page or list).</param>
|
||||
/// <param name="Unrelated">Bodies that are not about contents (ignored).</param>
|
||||
/// <param name="Unrecognized">Bodies with a shape the readers do not know.</param>
|
||||
/// <param name="NotSite">Bodies of a host that is not the site (not read).</param>
|
||||
/// <param name="NotRead">Responses whose body is not data and is not read at all (images, scripts...).</param>
|
||||
/// <param name="Contents">Contents the readers found.</param>
|
||||
/// <param name="Profiles">Profiles the readers found.</param>
|
||||
/// <param name="Dropped">Bodies that never reached the readers, by reason.</param>
|
||||
public sealed record ResponseGroup(
|
||||
HostKind HostKind,
|
||||
string? Page,
|
||||
string Pattern,
|
||||
string? ResourceType,
|
||||
string Mime,
|
||||
string Status,
|
||||
int Count,
|
||||
long Bytes,
|
||||
long MaxBytes,
|
||||
int Recognized,
|
||||
int Empty,
|
||||
int Unrelated,
|
||||
int Unrecognized,
|
||||
int NotSite,
|
||||
int NotRead,
|
||||
int Contents,
|
||||
int Profiles,
|
||||
IReadOnlyList<DropCount> Dropped);
|
||||
|
||||
public sealed record DropCount(BodyDropReason Reason, int Count);
|
||||
|
||||
public sealed record UnknownShape(string Structure, string Pattern, int Count);
|
||||
|
||||
public sealed record VerdictCount(string Verdict, int Count);
|
||||
|
||||
public sealed record TargetCount(string Target, TargetCheckStatus Status, int Count);
|
||||
|
||||
public sealed record RecipeLine(DateTimeOffset At, RecipeKind Kind, RecipeStatus Status, string? Signal, int Actions, int NewEntries)
|
||||
{
|
||||
/// <summary>For a recipe that failed on an unexpected error: the type name of the exception, never its message.</summary>
|
||||
public string? Error { get; init; }
|
||||
}
|
||||
|
||||
public sealed record SignalLine(DateTimeOffset At, SignalLevel Level, string Code);
|
||||
|
||||
public sealed record DenialCount(ActionKind Action, DenialReason Reason, int Count);
|
||||
|
||||
/// <summary>Saves of contents read by the recipes: how many, and how many files they put in the download queue.</summary>
|
||||
/// <param name="Outcome">A <see cref="SaveOutcome"/> name, or «Completed» for a «Post singolo» completion.</param>
|
||||
public sealed record QueuedFiles(EntryKind Kind, string Outcome, int Saves, int Files, int Skipped);
|
||||
|
||||
public sealed record DownloadGroup(EntryKind Kind, DownloadStep Step, int Count, long Bytes)
|
||||
{
|
||||
/// <summary>Why a file failed or waits for another attempt (<see cref="DownloadCauses"/>), when the queue said.</summary>
|
||||
public string? Cause { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>Items left out because their list reached its cap (<see cref="CollectionDiagnostics"/>).</summary>
|
||||
public sealed record TraceOverflow
|
||||
{
|
||||
public int Pages { get; init; }
|
||||
|
||||
public int Navigations { get; init; }
|
||||
|
||||
public int Responses { get; init; }
|
||||
|
||||
public int UnknownShapes { get; init; }
|
||||
|
||||
public int Signals { get; init; }
|
||||
|
||||
public int Recipes { get; init; }
|
||||
|
||||
/// <summary>Bodies forgotten while still waiting for their reading (too many responses at once).</summary>
|
||||
public int Requests { get; init; }
|
||||
|
||||
/// <summary>Sizes, readings or drops that arrived after their own trace was closed (counted in the trace open then).</summary>
|
||||
public int Late { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>What there is to report, with what the report must say about itself.</summary>
|
||||
/// <param name="Traces">The traces, oldest first.</param>
|
||||
/// <param name="DamagedLines">Lines of the log that could not be read (a stop in the middle of a write).</param>
|
||||
/// <param name="RecorderFaults">Errors the recorder swallowed since Febe started (a failed write among them).</param>
|
||||
public sealed record DiagnosticCollection(IReadOnlyList<SessionTrace> Traces, int DamagedLines = 0, int RecorderFaults = 0)
|
||||
{
|
||||
/// <summary>Day files of the log that could not be opened or read: their sessions are missing.</summary>
|
||||
public int UnreadableFiles { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Sessions whose last line in the log is in progress, not running now and not closed by a shutdown: Febe stopped
|
||||
/// without closing them (a crash, a kill), and what they did after their last line is missing.
|
||||
/// </summary>
|
||||
public int UnfinishedSessions { get; init; }
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(
|
||||
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
|
||||
UseStringEnumConverter = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonSerializable(typeof(SessionTrace))]
|
||||
internal sealed partial class DiagnosticsJsonContext : JsonSerializerContext;
|
||||
Reference in new issue
Block a user