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
@@ -1,5 +1,6 @@
|
||||
using System.Text.Json;
|
||||
using Febe.Core.Abstractions;
|
||||
using Febe.Core.Collection.Diagnostics;
|
||||
using Febe.Core.Collection.Readers;
|
||||
|
||||
namespace Febe.Core.Collection.Recipes;
|
||||
@@ -39,6 +40,12 @@ public sealed class CaptureCollector : IResponseConsumer, IResponseObserver
|
||||
|
||||
public ShapeReader Reader => _reader;
|
||||
|
||||
/// <summary>
|
||||
/// The recorder of the diagnostic report (issue #39), told what the readers did with every body, also the ones
|
||||
/// not kept (another host, unrelated); null: nothing is recorded.
|
||||
/// </summary>
|
||||
public CollectionDiagnostics? Diagnostics { get; init; }
|
||||
|
||||
/// <summary>How long a data response may stay «on its way» before it is forgotten (its body may never come).</summary>
|
||||
public TimeSpan PendingLifetime { get; init; } = TimeSpan.FromSeconds(15);
|
||||
|
||||
@@ -165,10 +172,12 @@ public sealed class CaptureCollector : IResponseConsumer, IResponseObserver
|
||||
|
||||
if (response.HostKind != HostKind.Site)
|
||||
{
|
||||
Observe(response, null, body);
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = _reader.Read(body);
|
||||
Observe(response, result, body);
|
||||
if (result.ViewerId is { } viewerId)
|
||||
{
|
||||
lock (_gate)
|
||||
@@ -197,6 +206,28 @@ public sealed class CaptureCollector : IResponseConsumer, IResponseObserver
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tells the diagnostics what the readers made of a body; for an unknown shape, its strict key structure, taken
|
||||
/// now, while the document is alive. Never a reason to fail the reading.
|
||||
/// </summary>
|
||||
private void Observe(ResponseDescriptor response, ReadResult? result, JsonElement body)
|
||||
{
|
||||
if (Diagnostics is not { } diagnostics)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var structure = result?.Shape == ReadShape.Unrecognized ? KeyStructure.DescribeStrict(body) : null;
|
||||
diagnostics.ReadObserved(response, result, structure);
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
// Diagnostics are optional: the reading goes on as if they were not there.
|
||||
}
|
||||
}
|
||||
|
||||
void IResponseObserver.OnResponse(ResponseDescriptor response)
|
||||
{
|
||||
if (response.HostKind == HostKind.Site
|
||||
|
||||
Reference in new issue
Block a user