Class FileCosmosQueryLogSink
An ICosmosQueryLogSink that appends each diagnostics event as a single line of JSON (NDJSON / JSON Lines) to a file.
Inherited Members
Namespace: Benday.CosmosDb.Diagnostics
Assembly: Benday.CosmosDb.dll
Syntax
public sealed class FileCosmosQueryLogSink : ICosmosQueryLogSink, IDisposable
Remarks
Events are handed to an in-memory queue from Record(CosmosQueryDiagnostics) and written to disk by a single background thread, so the library's query-execution path is never blocked on file I/O. Dispose the sink (or let the host shut it down) to flush any queued events.
If the queue fills past QueueCapacity (default 10,000), new events are dropped. This keeps a stuck disk from growing memory without bound.
Constructors
| Edit this page View SourceFileCosmosQueryLogSink()
Declaration
public FileCosmosQueryLogSink()
FileCosmosQueryLogSink(CosmosFileLogSinkOptions)
Declaration
public FileCosmosQueryLogSink(CosmosFileLogSinkOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| CosmosFileLogSinkOptions | options |
FileCosmosQueryLogSink(IOptions<CosmosFileLogSinkOptions>)
DI-friendly constructor. Resolves options via the
IOptions<TOptions> pattern so consumers can register
CosmosFileLogSinkOptions with
services.Configure<CosmosFileLogSinkOptions>(...) or bind
from IConfiguration.
Declaration
[ActivatorUtilitiesConstructor]
public FileCosmosQueryLogSink(IOptions<CosmosFileLogSinkOptions> options)
Parameters
| Type | Name | Description |
|---|---|---|
| IOptions<CosmosFileLogSinkOptions> | options |
FileCosmosQueryLogSink(string)
Declaration
public FileCosmosQueryLogSink(string filePath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filePath |
Properties
| Edit this page View SourceDroppedCount
Number of events dropped because the queue was full. Useful for surfacing back-pressure in tests or health checks.
Declaration
public int DroppedCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceDispose()
Stops accepting new events and blocks until the background writer has flushed everything currently queued.
Declaration
public void Dispose()
Record(CosmosQueryDiagnostics)
Records a diagnostics event. Called synchronously from the library on the thread that executed the query.
Declaration
public void Record(CosmosQueryDiagnostics diagnostics)
Parameters
| Type | Name | Description |
|---|---|---|
| CosmosQueryDiagnostics | diagnostics | The diagnostics payload for this event. Never null. |