namespace SQLInsight.Core.Data;
///
/// Globally enabled trace flags (DBCC TRACESTATUS(-1)).
///
public sealed record TraceFlagSnapshot(DateTimeOffset CapturedAt, IReadOnlyList GlobalTraceFlags)
{
public bool IsEnabled(int flag) => GlobalTraceFlags.Contains(flag);
}
///
/// Pages SQL Server has recorded as damaged (msdb.dbo.suspect_pages, 823/824/825 errors).
///
public sealed record SuspectPageSnapshot(DateTimeOffset CapturedAt, IReadOnlyList Pages);
/// 1: 823/824 error, 2: bad checksum, 3: torn page, 4: restored, 5: repaired, 7: deallocated.
public sealed record SuspectPage(string DatabaseName, int FileId, long PageId, int EventType, int ErrorCount, DateTime LastUpdate)
{
/// Event types 4, 5 and 7 mean the page has been fixed.
public bool IsUnresolved => EventType is 1 or 2 or 3;
}
///
/// Plan cache composition (sys.dm_exec_cached_plans).
///
public sealed record PlanCacheSnapshot
{
public required DateTimeOffset CapturedAt { get; init; }
public required long TotalPlans { get; init; }
public required double TotalMb { get; init; }
/// Ad hoc plans used exactly once. A high share means plan cache bloat.
public required long SingleUseAdhocPlans { get; init; }
public required double SingleUseAdhocMb { get; init; }
}