polish(localdb): final integration-review fixes — drift XML doc, trim core deps, metrics doc/encapsulation
Claude-Session: https://claude.ai/code/session_01BL2Vu1ESDQ9SCN4gVKkdts
This commit is contained in:
@@ -24,6 +24,7 @@ public sealed class LocalDbMetrics : IDisposable
|
||||
private readonly Func<DateTimeOffset> _utcNow;
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>Creates the meter and its instruments. <paramref name="utcNow"/> is a test seam for the lag gauge's clock; null uses <see cref="DateTimeOffset.UtcNow"/>.</summary>
|
||||
public LocalDbMetrics(Func<DateTimeOffset>? utcNow = null)
|
||||
{
|
||||
_utcNow = utcNow ?? (() => DateTimeOffset.UtcNow);
|
||||
@@ -41,34 +42,40 @@ public sealed class LocalDbMetrics : IDisposable
|
||||
/// Supplies the current unacked oplog backlog for the <c>localdb.oplog.depth</c> gauge. Invoked
|
||||
/// only at collection time; a cheap synchronous SELECT is acceptable at that frequency.
|
||||
/// </summary>
|
||||
public Func<long>? OplogDepthProvider { get; set; }
|
||||
public Func<long>? OplogDepthProvider { get; internal set; }
|
||||
|
||||
/// <summary>Supplies the last successful sync time for the <c>localdb.sync.lag.seconds</c> gauge; null means no sync yet, and the gauge then reports no measurement.</summary>
|
||||
public Func<DateTimeOffset?>? LastSyncUtcProvider { get; set; }
|
||||
public Func<DateTimeOffset?>? LastSyncUtcProvider { get; internal set; }
|
||||
|
||||
/// <summary>The backing meter — exposed so a test <see cref="MeterListener"/> can filter by instance reference rather than the process-shared meter name.</summary>
|
||||
internal Meter Meter => _meter;
|
||||
|
||||
/// <summary>Adds <paramref name="count"/> rows applied from inbound delta batches to <c>localdb.sync.applied</c> (no-op when not positive).</summary>
|
||||
public void RecordApplied(long count)
|
||||
{
|
||||
if (count > 0) _applied.Add(count);
|
||||
}
|
||||
|
||||
/// <summary>Adds <paramref name="count"/> inbound rows that lost LWW to <c>localdb.sync.conflicts_discarded</c> (no-op when not positive).</summary>
|
||||
public void RecordConflictsDiscarded(long count)
|
||||
{
|
||||
if (count > 0) _conflictsDiscarded.Add(count);
|
||||
}
|
||||
|
||||
/// <summary>Adds <paramref name="count"/> poison / over-drift rows routed to the dead-letter table to <c>localdb.sync.dead_lettered</c> (no-op when not positive).</summary>
|
||||
public void RecordDeadLettered(long count)
|
||||
{
|
||||
if (count > 0) _deadLettered.Add(count);
|
||||
}
|
||||
|
||||
/// <summary>Increments <c>localdb.sync.reconnects</c> for one initiator reconnect attempt.</summary>
|
||||
public void RecordReconnect() => _reconnects.Add(1);
|
||||
|
||||
/// <summary>Increments <c>localdb.sync.snapshots</c> with <c>direction=sent</c> for one completed outbound snapshot.</summary>
|
||||
public void RecordSnapshotSent() =>
|
||||
_snapshots.Add(1, new KeyValuePair<string, object?>("direction", "sent"));
|
||||
|
||||
/// <summary>Increments <c>localdb.sync.snapshots</c> with <c>direction=received</c> for one completed inbound snapshot.</summary>
|
||||
public void RecordSnapshotReceived() =>
|
||||
_snapshots.Add(1, new KeyValuePair<string, object?>("direction", "received"));
|
||||
|
||||
@@ -99,6 +106,7 @@ public sealed class LocalDbMetrics : IDisposable
|
||||
return [new Measurement<double>(lag)];
|
||||
}
|
||||
|
||||
/// <summary>Disposes the backing meter; idempotent.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed)
|
||||
|
||||
Reference in New Issue
Block a user