Class AuditActor
A declared actor for work that has no authenticated HTTP caller behind it — a hosted service, a message handler, a scheduled job.
public sealed record AuditActor : IEquatable<AuditActor>
- Inheritance
-
AuditActor
- Implements
- Inherited Members
Remarks
Declared rather than inferred, on purpose. The application knows it is running a nightly retention sweep; nothing about the call stack does. Push one of these around the unit of work and every audit entry written inside it is attributed to that actor instead of falling through to Unknown.
Constructors
AuditActor(string, AuditCallerType, AuditCallerSource, Guid?, string)
A declared actor for work that has no authenticated HTTP caller behind it — a hosted service, a message handler, a scheduled job.
public AuditActor(string Identity, AuditCallerType CallerType = AuditCallerType.System, AuditCallerSource CallerSource = AuditCallerSource.Background, Guid? CorrelationId = null, string TeamKey = null)
Parameters
IdentitystringWho to record — a service or job name (
"retention-sweep","fortdocs-worker"). This lands in CallerIdentity, so make it something a reader can act on.CallerTypeAuditCallerTypeDefaults to System.
CallerSourceAuditCallerSourceDefaults to Background.
CorrelationIdGuid?Optional. Set it per unit of work — one value per claimed job — so every entry that job writes can be pulled back together. Without it each entry gets its own generated id and the grouping is lost.
TeamKeystringOptional. The team this work acts on. Background code has no selected team for the toolkit to infer one from, so without it entries are recorded with no team and cannot be found on a team-scoped audit view. Declaring it here means a job that works on one team states it once instead of on every entry; an explicit
teamKeypassed to Create(string, string, string, long, bool, string, string, IReadOnlyDictionary<string, string>) still wins, for a job that crosses teams.
Remarks
Declared rather than inferred, on purpose. The application knows it is running a nightly retention sweep; nothing about the call stack does. Push one of these around the unit of work and every audit entry written inside it is attributed to that actor instead of falling through to Unknown.
Properties
CallerSource
Defaults to Background.
public AuditCallerSource CallerSource { get; init; }
Property Value
CallerType
Defaults to System.
public AuditCallerType CallerType { get; init; }
Property Value
CorrelationId
Optional. Set it per unit of work — one value per claimed job — so every entry that job writes can be pulled back together. Without it each entry gets its own generated id and the grouping is lost.
public Guid? CorrelationId { get; init; }
Property Value
- Guid?
Identity
Who to record — a service or job name ("retention-sweep", "fortdocs-worker"). This lands
in CallerIdentity, so make it something a reader can act on.
public string Identity { get; init; }
Property Value
TeamKey
Optional. The team this work acts on. Background code has no selected team for the toolkit to infer
one from, so without it entries are recorded with no team and cannot be found on a team-scoped audit
view. Declaring it here means a job that works on one team states it once instead of on every entry;
an explicit teamKey passed to
Create(string, string, string, long, bool, string, string, IReadOnlyDictionary<string, string>)
still wins, for a job that crosses teams.
public string TeamKey { get; init; }