Class QueryGuardSession
- Namespace
- QueryGuard
- Assembly
- QueryGuard.Core.dll
The unit QueryGuard measures: one HTTP request, or one integration test.
public sealed class QueryGuardSession
- Inheritance
-
QueryGuardSession
- Inherited Members
Remarks
A session has two states. While open it accepts records; once completed it is frozen and exposes an immutable, deterministically ordered view of what it saw. That boundary matters. A session that quietly accepted a late record would produce results that depend on timing, which is the one thing a testing tool cannot afford.
Sessions never look up the ambient session themselves. They are handed to the interceptor
through IQueryGuardSessionAccessor, which keeps the EF Core interceptor stateless and
therefore safe to share as the singleton EF Core registers it as. See
docs/decisions/0002-session-propagation.md.
Constructors
- QueryGuardSession(string, QueryGuardPolicy, IQueryGuardRedactor?, Func<DateTimeOffset>?)
Initializes a new instance of the QueryGuardSession class.
Properties
- CommandCount
Gets how many commands this session has captured so far.
- DroppedRecordCount
Gets how many records arrived after this session was completed.
- Elapsed
Gets how long the session was open, or how long it has been open so far.
- Id
Gets the identifier of this session. Included in reports so records from concurrent sessions can be told apart during an investigation.
- IsCompleted
Gets a value indicating whether this session has been completed and is now frozen.
- Name
Gets what this session measures.
- Policy
Gets the policy this session is evaluated against.
- StartedAt
Gets when the session opened, in UTC.
Methods
- Complete()
Completes the session and returns an immutable snapshot of what it captured.
- Record(QueryCommandKind, QueryFingerprint, TimeSpan, string?, int, bool, string?, IReadOnlyList<string>?, Func<string?>?)
Records one observed command and assigns it a sequence number.
- ToString()
Returns a string that represents the current object.