Table of Contents

Method BeginAttempt

Namespace
MailFathom.Infrastructure.Observability
Assembly
MailFathom.Infrastructure.dll

BeginAttempt(JobType, JobTraceContext?)

Opens the span one attempt at a job is reported as, and returns the scope that ends it.

public JobQueueTelemetry.JobAttemptScope BeginAttempt(JobType jobType, JobTraceContext? enqueuedTrace)

Parameters

jobType JobType

The kind of work being attempted, which is the only thing about the job the span names.

enqueuedTrace JobTraceContext

The trace the job was enqueued inside, or null when its row records none.

Returns

JobQueueTelemetry.JobAttemptScope

The scope, which the caller must dispose; a scope disposed without Ended(JobExecutionResult) reports an attempt that produced no result.

Remarks

The span is opened around the attempt rather than around the pass that dispatched it, so a pass running several jobs at once produces one span each instead of one span covering all of them. Nothing about the job itself reaches it beyond the type: not the job's identifier, not the account, and above all not the idempotency key, which is composed of folder aliases and message occurrences.

A link rather than a parent, and the difference is the queue. The work that enqueued the job ended before a worker claimed it — minutes earlier, or on another replica, or before a restart — so making the attempt that work's child would ask a span store to hold a trace open for as long as the queue is deep. A link says the same thing without that: the attempt is its own trace, and the cause is one step away rather than a search through logs. A job whose row records nothing to link to opens the same span with no link, which is every row written before the column existed.