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
@@ -198,7 +198,7 @@ public sealed class ResponseTap : IAsyncDisposable
|
||||
{
|
||||
if (_inFlight.TryRemove(key, out _))
|
||||
{
|
||||
NotifyDropped(key);
|
||||
NotifyDropped(key, BodyDropReason.Reconnected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,17 +273,22 @@ public sealed class ResponseTap : IAsyncDisposable
|
||||
|
||||
private void OnLoadingFinished(JsonElement p)
|
||||
{
|
||||
if (!p.TryGetProperty("requestId", out var idElement) || idElement.GetString() is not { } requestId
|
||||
|| !_inFlight.TryRemove(requestId, out var pending))
|
||||
if (!p.TryGetProperty("requestId", out var idElement) || idElement.GetString() is not { } requestId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var length = p.TryGetProperty("encodedDataLength", out var len) && len.TryGetDouble(out var d) ? d : 0;
|
||||
NotifyLoadingFinished(requestId, length);
|
||||
if (!_inFlight.TryRemove(requestId, out var pending))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (length > _options.MaxBodyBytes)
|
||||
{
|
||||
Interlocked.Increment(ref _skipped);
|
||||
NotifyDropped(requestId);
|
||||
NotifyDropped(requestId, BodyDropReason.TooLarge);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -295,7 +300,7 @@ public sealed class ResponseTap : IAsyncDisposable
|
||||
if (p.TryGetProperty("requestId", out var idElement) && idElement.GetString() is { } requestId
|
||||
&& _inFlight.TryRemove(requestId, out _))
|
||||
{
|
||||
NotifyDropped(requestId);
|
||||
NotifyDropped(requestId, BodyDropReason.LoadingFailed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,7 +323,7 @@ public sealed class ResponseTap : IAsyncDisposable
|
||||
{
|
||||
if (key != loader && _inFlight.TryRemove(key, out _))
|
||||
{
|
||||
NotifyDropped(key);
|
||||
NotifyDropped(key, BodyDropReason.FrameNavigated);
|
||||
}
|
||||
}
|
||||
Publish(frame.TryGetProperty("url", out var u) ? u.GetString() : null, sameDocument: false);
|
||||
@@ -373,7 +378,7 @@ public sealed class ResponseTap : IAsyncDisposable
|
||||
// One unexpected body must not stop the capture of the following ones. Only the type: the message
|
||||
// of a parsing error may quote the body.
|
||||
_log.Warn($"Cattura: errore imprevisto nella lettura di una risposta ({ex.GetType().Name}).");
|
||||
NotifyDropped(pending.Descriptor.RequestId);
|
||||
NotifyDropped(pending.Descriptor.RequestId, BodyDropReason.Unexpected);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -394,7 +399,7 @@ public sealed class ResponseTap : IAsyncDisposable
|
||||
|
||||
if (consumers.Length == 0)
|
||||
{
|
||||
NotifyDropped(descriptor.RequestId);
|
||||
NotifyDropped(descriptor.RequestId, BodyDropReason.NoConsumers);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -408,16 +413,22 @@ public sealed class ResponseTap : IAsyncDisposable
|
||||
// The body may already be evicted from the browser's buffer, or the page navigated away.
|
||||
Interlocked.Increment(ref _bodyErrors);
|
||||
_log.Debug($"Cattura: corpo non disponibile ({ex.GetType().Name}).");
|
||||
NotifyDropped(descriptor.RequestId);
|
||||
NotifyDropped(descriptor.RequestId, ex is TimeoutException ? BodyDropReason.Timeout : BodyDropReason.Unavailable);
|
||||
return;
|
||||
}
|
||||
|
||||
var delivered = bytes is null ? 0
|
||||
: pending.IsPageDocument ? await ConsumeDocumentAsync(descriptor, bytes, consumers, ct).ConfigureAwait(false)
|
||||
if (bytes is null)
|
||||
{
|
||||
NotifyDropped(descriptor.RequestId, BodyDropReason.Unavailable);
|
||||
return;
|
||||
}
|
||||
|
||||
var delivered = pending.IsPageDocument
|
||||
? await ConsumeDocumentAsync(descriptor, bytes, consumers, ct).ConfigureAwait(false)
|
||||
: await ConsumeBodyAsync(descriptor, bytes, consumers, ct).ConfigureAwait(false);
|
||||
if (delivered == 0)
|
||||
{
|
||||
NotifyDropped(descriptor.RequestId);
|
||||
NotifyDropped(descriptor.RequestId, pending.IsPageDocument ? BodyDropReason.NoJsonBlock : BodyDropReason.NotJson);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,14 +526,31 @@ public sealed class ResponseTap : IAsyncDisposable
|
||||
return decoded;
|
||||
}
|
||||
|
||||
/// <summary>Tells the observers that a body they may be waiting for will not come.</summary>
|
||||
private void NotifyDropped(string requestId)
|
||||
/// <summary>Tells the observers that a body they may be waiting for will not come, and why.</summary>
|
||||
private void NotifyDropped(string requestId, BodyDropReason reason)
|
||||
{
|
||||
foreach (var observer in SnapshotObservers())
|
||||
{
|
||||
try
|
||||
{
|
||||
observer.OnBodyDropped(requestId);
|
||||
observer.OnBodyDropped(requestId, reason);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Warn("Cattura: errore in un osservatore delle risposte.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Tells the observers how many bytes a response took on the network (every response, read or not).</summary>
|
||||
private void NotifyLoadingFinished(string requestId, double encodedBytes)
|
||||
{
|
||||
var bytes = encodedBytes is > 0 and < long.MaxValue ? (long)encodedBytes : 0;
|
||||
foreach (var observer in SnapshotObservers())
|
||||
{
|
||||
try
|
||||
{
|
||||
observer.OnLoadingFinished(requestId, bytes);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user