Class JobQueueTelemetry
- Namespace
- MailFathom.Infrastructure.Observability
- Assembly
- MailFathom.Infrastructure.dll
Makes durable background work legible from outside the process: what ran, how long it took, and what is waiting.
public sealed class JobQueueTelemetry
- Inheritance
-
JobQueueTelemetry
- Inherited Members
Remarks
Six instruments, and each answers a question the others cannot. The attempts and their durations say what the queue is doing; the retries say how much of that is work being repeated, which is what separates an instance that is busy from one that is failing and trying again; the dead letters say what has stopped, which is the only one of the four that waits for a person. The depth beside them is the level the first three are a rate against — a backlog is visible there while it is still small, and long before the effect of it reaches anything else. The two beside those belong to recurring dispatch: what each schedule's occasion did, and how many occasions were deliberately not run, which is the one thing a queue's own instruments could never show — an occasion that was skipped enqueued nothing and would otherwise be indistinguishable from an interval nobody declared.
Dead letters carry their own instrument rather than being a dimension of the attempts, because the classification that ended a job belongs on that measurement and on no other: a permanent failure is a defect or a declaration to fix, and a transient one that exhausted its attempts is a dependency that stayed broken. Putting that dimension on every attempt would make it a tag reading "none" on almost every series.
The depth is a gauge over the last figure the worker measured rather than a live count, for the reason the embedding backlog's is: an exact live count is a query, and making it a gauge would put that query on whatever interval a collector happened to be configured with. It is published per type and replaced whole, so a type whose queue emptied reports zero rather than its last non-zero depth, and it saturates at the configured depth bound — which is exactly where enqueuing is already being refused as backpressure.
Nothing published here is mail or derived from it. The dimensions are MailFathom's own closed sets — a job type's name, an execution outcome, and a failure classification — and the values are counts and durations. The job's payload, its idempotency key, its account, and the reason recorded against a failure all stay off every measurement: a key names folders and occurrences and a reason is unbounded in the way a metric dimension may not be, so both are read from the queue rather than from a dashboard.
Constructors
- JobQueueTelemetry()
Initializes the instruments every job attempt and every queue measurement reports through.
Methods
- RecordAttempt(JobExecutionResult)
Records one attempt: that it happened, how long it took, and what became of the job.
- RecordQueueDepth(IReadOnlyList<JobQueueDepthReading>)
Publishes what the worker last measured the queue's depth to be.
- RecordScheduleDispatch(JobScheduleDispatch)
Records what a pass decided about one schedule, and how many occasions that decision passed over.