Reference

TraxAuditChannel

Package Trax.Api.GraphQL.AuditNamespace Trax.Api.GraphQL.AuditSource TraxAuditChannel.cs

NO WARRANTY. Trax auth is plumbing, not a security product. You are solely responsible for securing systems that use it. See API Security.

The bounded queue between the audit listener, which offers entries, and the background writer, which drains them. AddAudit registers it as a singleton. It owns the Trax.Audit meter and its trax.audit.dropped counter.

Signature

public sealed class TraxAuditChannel : IDisposable
{
    public const string MeterName = "Trax.Audit";
    public const string DroppedCounterName = "trax.audit.dropped";
 
    public TraxAuditChannel(IOptions<TraxAuditOptions> options, ILogger<TraxAuditChannel> logger);
 
    public long TotalDropped { get; }
}

Members

MemberValue
MeterNameTrax.Audit, the System.Diagnostics.Metrics meter the counter belongs to.
DroppedCounterNametrax.audit.dropped, a Counter<long> with unit {entry}.
TotalDroppedEntries dropped since the process started, the same count the counter reports.

Behavior

The channel holds up to TraxAuditOptions.ChannelCapacity entries and never blocks the listener: an entry offered while it is full, or after the writer has stopped accepting entries for shutdown, is refused and counted as dropped.

trax.audit.dropped counts each entry that will never reach the sink, once:

  • the listener failed to capture or build it;
  • the channel was full, or shutting down;
  • the sink refused its batch after every retry;
  • shutdown ran out of time before it was written.

A drop logs a warning with the running total, at most once every five seconds.

Example

Export the meter with OpenTelemetry, and alert on a non-zero trax.audit.dropped:

builder.Services.AddOpenTelemetry()
    .WithMetrics(metrics => metrics.AddMeter(TraxAuditChannel.MeterName));

See also