pub struct AuthEvent {
pub event: String,
pub user_id: Option<String>,
pub provider: Option<String>,
pub status: String,
pub duration_ms: f64,
pub error: Option<String>,
pub timestamp: String,
pub request_id: Option<String>,
}Expand description
A structured log record for a single authentication event.
Constructed with AuthEvent::new and populated via builder methods.
Call AuthEvent::log to emit the record through tracing.
§Example
use fraiseql_auth::AuthEvent;
let event = AuthEvent::new("login")
.with_user_id("user123".to_string())
.with_provider("google".to_string())
.success(42.5);
event.log();Fields§
§event: StringName of the authentication event (e.g., "login", "token_refresh").
user_id: Option<String>Optional authenticated user ID associated with this event.
provider: Option<String>OAuth provider name (e.g., "google", "okta").
status: StringOutcome: "started", "success", or "error".
duration_ms: f64Duration of the operation in milliseconds.
error: Option<String>Error message if the operation failed.
timestamp: StringRFC 3339 timestamp of when this event was created.
request_id: Option<String>Optional correlation ID for tracing a request across services.
Implementations§
Source§impl AuthEvent
impl AuthEvent
Sourcepub fn with_user_id(self, user_id: String) -> Self
pub fn with_user_id(self, user_id: String) -> Self
Set the user ID associated with this event.
Sourcepub fn with_provider(self, provider: String) -> Self
pub fn with_provider(self, provider: String) -> Self
Set the OAuth provider name for this event.
Sourcepub fn with_request_id(self, request_id: String) -> Self
pub fn with_request_id(self, request_id: String) -> Self
Set the request correlation ID for distributed tracing.
Sourcepub fn success(self, duration_ms: f64) -> Self
pub fn success(self, duration_ms: f64) -> Self
Mark the event as successful and record its duration.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AuthEvent
impl RefUnwindSafe for AuthEvent
impl Send for AuthEvent
impl Sync for AuthEvent
impl Unpin for AuthEvent
impl UnsafeUnpin for AuthEvent
impl UnwindSafe for AuthEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more