Table of Contents

Interface IDatabaseMonitor

Namespace
Tharga.MongoDB
Assembly
Tharga.MongoDB.dll
public interface IDatabaseMonitor

Methods

CleanAsync(CollectionInfo, bool)

Task<CleanInfo> CleanAsync(CollectionInfo collectionInfo, bool cleanGuids)

Parameters

collectionInfo CollectionInfo
cleanGuids bool

Returns

Task<CleanInfo>

CompareSchemaAsync(CollectionInfo, int, CancellationToken)

Sample up to sampleSize documents and return a three-way diff between the C# entity type's public properties, the registered entity-type names, and the field set observed in the sample. Top-level fields only.

Task<SchemaComparisonDto> CompareSchemaAsync(CollectionInfo collectionInfo, int sampleSize, CancellationToken cancellationToken = default)

Parameters

collectionInfo CollectionInfo
sampleSize int
cancellationToken CancellationToken

Returns

Task<SchemaComparisonDto>

DropIndexAsync(CollectionInfo)

Task<(int Before, int After)> DropIndexAsync(CollectionInfo collectionInfo)

Parameters

collectionInfo CollectionInfo

Returns

Task<(int Before, int After)>

FindConnectionIdBySource(string)

Find the SignalR connection ID of a connected agent by source name. Returns null if no connected agent matches.

string FindConnectionIdBySource(string sourceName)

Parameters

sourceName string

Returns

string

GetCallCounts()

Get call counts per collection fingerprint key.

IReadOnlyDictionary<string, int> GetCallCounts()

Returns

IReadOnlyDictionary<string, int>

GetCallDtos(CallType)

Get serialization-friendly representation of calls by type.

IEnumerable<CallDto> GetCallDtos(CallType callType)

Parameters

callType CallType

Returns

IEnumerable<CallDto>

GetCallSummary()

Get call summary grouped by collection and function (for chatty/slow detection).

IEnumerable<CallSummaryDto> GetCallSummary()

Returns

IEnumerable<CallSummaryDto>

GetCalls(CallType)

IEnumerable<CallInfo> GetCalls(CallType callType)

Parameters

callType CallType

Returns

IEnumerable<CallInfo>

GetCollectionSources(string)

Get the source names that have reported a given collection (by fingerprint key).

IReadOnlyCollection<string> GetCollectionSources(string fingerprintKey)

Parameters

fingerprintKey string

Returns

IReadOnlyCollection<string>

GetConfigurations()

IEnumerable<ConfigurationName> GetConfigurations()

Returns

IEnumerable<ConfigurationName>

GetConnectionPoolState()

Get aggregate connection pool state.

ConnectionPoolStateDto GetConnectionPoolState()

Returns

ConnectionPoolStateDto

GetDocumentAsync(CollectionInfo, string, CancellationToken)

Fetch a single raw document by id. idRaw is auto-detected as Guid → ObjectId → string. Returns null when no document matches. Returned Json is MongoDB Extended JSON.

Task<DocumentDto> GetDocumentAsync(CollectionInfo collectionInfo, string idRaw, CancellationToken cancellationToken = default)

Parameters

collectionInfo CollectionInfo
idRaw string
cancellationToken CancellationToken

Returns

Task<DocumentDto>

GetErrorSummary()

Get error summary grouped by exception type and collection.

IEnumerable<ErrorSummaryDto> GetErrorSummary()

Returns

IEnumerable<ErrorSummaryDto>

GetExplainAsync(Guid, CancellationToken)

Resolve the explain plan for a specific call.

Task<string> GetExplainAsync(Guid callKey, CancellationToken cancellationToken = default)

Parameters

callKey Guid
cancellationToken CancellationToken

Returns

Task<string>

GetIndexBlockersAsync(CollectionInfo, string)

Task<IEnumerable<string[]>> GetIndexBlockersAsync(CollectionInfo collectionInfo, string indexName)

Parameters

collectionInfo CollectionInfo
indexName string

Returns

Task<IEnumerable<string[]>>

GetInstanceAsync(CollectionFingerprint)

Task<CollectionInfo> GetInstanceAsync(CollectionFingerprint fingerprint)

Parameters

fingerprint CollectionFingerprint

Returns

Task<CollectionInfo>

GetInstancesAsync(bool, string)

IAsyncEnumerable<CollectionInfo> GetInstancesAsync(bool fullDatabaseScan = false, string filter = null)

Parameters

fullDatabaseScan bool
filter string

Returns

IAsyncEnumerable<CollectionInfo>

GetMonitorClientDetail(string, int)

Atomic snapshot of everything a single agent has contributed: its MonitorClientDto, the collections it has reported, its most recent recentCallLimit calls, and its latest queue state. Returns null when no agent matches sourceName. Powers the per-agent detail dialog.

MonitorClientDetail GetMonitorClientDetail(string sourceName, int recentCallLimit = 20)

Parameters

sourceName string
recentCallLimit int

Returns

MonitorClientDetail

GetMonitorClients()

Get all known monitoring agents (connected and recently disconnected).

IEnumerable<MonitorClientDto> GetMonitorClients()

Returns

IEnumerable<MonitorClientDto>

GetPerSourceQueueState()

Get per-source queue state for all known sources (local + remote).

IReadOnlyDictionary<string, ConnectionPoolStateDto> GetPerSourceQueueState()

Returns

IReadOnlyDictionary<string, ConnectionPoolStateDto>

GetSlowCallsWithIndexInfoAsync()

Get slow calls with index coverage info (for missing index detection).

IAsyncEnumerable<SlowCallWithIndexInfoDto> GetSlowCallsWithIndexInfoAsync()

Returns

IAsyncEnumerable<SlowCallWithIndexInfoDto>

GetSubscriptions()

Get active subscriptions and their subscriber counts. Keys are topic names (e.g. "LiveMonitoringMarker"), values are subscriber counts.

IReadOnlyDictionary<string, int> GetSubscriptions()

Returns

IReadOnlyDictionary<string, int>

IngestCall(CallDto)

Ingest an externally produced call (e.g. from a remote agent) into the monitor pipeline. The call will appear in GetCalls, summaries, and Blazor components.

void IngestCall(CallDto call)

Parameters

call CallDto

IngestClientConnected(MonitorClientDto)

Register a connected monitoring agent.

void IngestClientConnected(MonitorClientDto client)

Parameters

client MonitorClientDto

IngestClientDisconnected(string)

Mark a monitoring agent as disconnected.

void IngestClientDisconnected(string connectionId)

Parameters

connectionId string

IngestCollectionInfo(RemoteCollectionInfoDto, string)

Ingest collection metadata from a remote agent.

void IngestCollectionInfo(RemoteCollectionInfoDto collectionInfo, string connectionId = null)

Parameters

collectionInfo RemoteCollectionInfoDto
connectionId string

IngestQueueMetric(string, int, int, double?)

Ingest a queue metric snapshot from a remote agent.

void IngestQueueMetric(string sourceName, int queueCount, int executingCount, double? waitTimeMs)

Parameters

sourceName string
queueCount int
executingCount int
waitTimeMs double?

ListDocumentsAsync(CollectionInfo, DocumentListQuery, CancellationToken)

List up to Limit raw documents from the collection. FilterJson and SortJson are parsed via BsonDocument.Parse; invalid JSON throws FormatException.

Task<DocumentListDto> ListDocumentsAsync(CollectionInfo collectionInfo, DocumentListQuery query, CancellationToken cancellationToken = default)

Parameters

collectionInfo CollectionInfo
query DocumentListQuery
cancellationToken CancellationToken

Returns

Task<DocumentListDto>

RefreshStatsAsync(CollectionFingerprint)

Task RefreshStatsAsync(CollectionFingerprint fingerprint)

Parameters

fingerprint CollectionFingerprint

Returns

Task

ResetAsync()

Task ResetAsync()

Returns

Task

ResetCalls()

void ResetCalls()

RestoreAllIndicesAsync(Func<CollectionInfo, bool>, IProgress<IndexAssureProgress>, CancellationToken)

Iterates every known collection (via GetInstancesAsync(bool, string)) and calls RestoreIndexAsync(CollectionInfo, bool) on each one. Use to apply newly added indexes across already-deployed environments without restarting consumer apps.

Task<IndexAssureSummary> RestoreAllIndicesAsync(Func<CollectionInfo, bool> filter = null, IProgress<IndexAssureProgress> progress = null, CancellationToken cancellationToken = default)

Parameters

filter Func<CollectionInfo, bool>

Optional predicate; collections returning false are skipped.

progress IProgress<IndexAssureProgress>

Optional progress reporter — fires once per collection.

cancellationToken CancellationToken

Cancels the iteration between collections.

Returns

Task<IndexAssureSummary>

RestoreIndexAsync(CollectionInfo, bool)

Task RestoreIndexAsync(CollectionInfo collectionInfo, bool force)

Parameters

collectionInfo CollectionInfo
force bool

Returns

Task

TouchAsync(CollectionInfo)

Task TouchAsync(CollectionInfo collectionInfo)

Parameters

collectionInfo CollectionInfo

Returns

Task

Events

CollectionDroppedEvent

event EventHandler<CollectionDroppedEventArgs> CollectionDroppedEvent

Event Type

EventHandler<CollectionDroppedEventArgs>

CollectionInfoChangedEvent

event EventHandler<CollectionInfoChangedEventArgs> CollectionInfoChangedEvent

Event Type

EventHandler<CollectionInfoChangedEventArgs>

MonitorClientsChanged

Raised when the list of connected monitoring agents changes.

event EventHandler MonitorClientsChanged

Event Type

EventHandler