fix(localdb): telemetry review fixes — meter naming, snapshot status, session-count Connected
Claude-Session: https://claude.ai/code/session_01BL2Vu1ESDQ9SCN4gVKkdts
This commit is contained in:
+9
-9
@@ -35,24 +35,24 @@ public static class ReplicationServiceCollectionExtensions
|
||||
|
||||
// Telemetry is optional but always registered here; the sessions/adapters hold nullable
|
||||
// references and null-guard every call, so a consumer that never collects metrics is
|
||||
// unaffected. The oplog-depth / lag / backlog observers poll a cheap synchronous store SELECT.
|
||||
services.TryAddSingleton<SyncStatus>(sp =>
|
||||
// unaffected. One OplogStore instance backs both the status backlog and the depth gauge
|
||||
// (it is stateless over the db, so sharing is free); its observers poll a cheap
|
||||
// synchronous SELECT.
|
||||
services.TryAddSingleton(sp =>
|
||||
{
|
||||
var db = SyncSessionFactory.RequireSqlite(sp.GetRequiredService<ILocalDb>(), nameof(SyncStatus));
|
||||
var db = SyncSessionFactory.RequireSqlite(sp.GetRequiredService<ILocalDb>(), nameof(OplogStore));
|
||||
var options = sp.GetRequiredService<IOptions<ReplicationOptions>>().Value;
|
||||
var store = new OplogStore(db, options);
|
||||
return new SyncStatus { OplogBacklogProvider = store.GetOplogDepthSync };
|
||||
return new OplogStore(db, options);
|
||||
});
|
||||
services.TryAddSingleton<SyncStatus>(sp =>
|
||||
new SyncStatus { OplogBacklogProvider = sp.GetRequiredService<OplogStore>().GetOplogDepthSync });
|
||||
services.TryAddSingleton<ISyncStatus>(sp => sp.GetRequiredService<SyncStatus>());
|
||||
services.TryAddSingleton<LocalDbMetrics>(sp =>
|
||||
{
|
||||
var db = SyncSessionFactory.RequireSqlite(sp.GetRequiredService<ILocalDb>(), nameof(LocalDbMetrics));
|
||||
var options = sp.GetRequiredService<IOptions<ReplicationOptions>>().Value;
|
||||
var store = new OplogStore(db, options);
|
||||
var status = sp.GetRequiredService<SyncStatus>();
|
||||
return new LocalDbMetrics
|
||||
{
|
||||
OplogDepthProvider = store.GetOplogDepthSync,
|
||||
OplogDepthProvider = sp.GetRequiredService<OplogStore>().GetOplogDepthSync,
|
||||
LastSyncUtcProvider = () => status.LastSyncUtc,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user