pub struct ClockDriftProcessor { /* private fields */ }
Expand description
Corrects clock drift based on the sender’s and receivers timestamps.
Clock drift correction applies to all timestamps in the event protocol. This includes especially the event’s timestamp, breadcrumbs and spans.
There is a minimum clock drift of 55 minutes to compensate for network latency and small clock drift on the sender’s machine, but allow to detect timezone differences. For differences lower than that, no correction is performed.
Clock drift is corrected in both ways:
-
The drift is added to timestamps if the received time is after the send time. This indicates that the sender’s clock was lagging behind. For instance, if an event was received with yesterday’s timestamp, one day is added to all timestamps.
-
The drift is subtracted from timestamps if the received time is before the send time. This indicates that the sender’s clock was running ahead. For instance, if an event was received with tomorrow’s timestamp, one day is subtracted from all timestamps.
Implementations§
source§impl ClockDriftProcessor
impl ClockDriftProcessor
sourcepub fn new(sent_at: Option<DateTime<Utc>>, received_at: DateTime<Utc>) -> Self
pub fn new(sent_at: Option<DateTime<Utc>>, received_at: DateTime<Utc>) -> Self
Creates a new ClockDriftProcessor
.
If no sent_at
timestamp is provided, then clock drift correction is disabled. The drift is
calculated from the signed difference between the receiver’s and the sender’s timestamp.
sourcepub fn at_least(self, lower_bound: Duration) -> Self
pub fn at_least(self, lower_bound: Duration) -> Self
Limits clock drift correction to a minimum duration.
If the detected clock drift is lower than the given duration, no correction is performed and
is_drifted
returns false
. By default, there is no lower bound and every drift is
corrected.
sourcepub fn error_kind(self, kind: ErrorKind) -> Self
pub fn error_kind(self, kind: ErrorKind) -> Self
Use the given error kind for the attached eventerror instead of the default
ErrorKind::ClockDrift
.
sourcepub fn is_drifted(&self) -> bool
pub fn is_drifted(&self) -> bool
Returns true
if the clocks are significantly drifted.
sourcepub fn process_timestamp(&self, timestamp: &mut UnixTimestamp)
pub fn process_timestamp(&self, timestamp: &mut UnixTimestamp)
Processes the given UnixTimestamp
by applying clock drift correction.
sourcepub fn process_datetime(&self, datetime: &mut DateTime<Utc>)
pub fn process_datetime(&self, datetime: &mut DateTime<Utc>)
Processes the given DateTime
.
Trait Implementations§
source§impl Debug for ClockDriftProcessor
impl Debug for ClockDriftProcessor
source§impl Processor for ClockDriftProcessor
impl Processor for ClockDriftProcessor
fn process_event( &mut self, event: &mut Event, _meta: &mut Meta, state: &ProcessingState<'_>, ) -> ProcessingResult
fn process_timestamp( &mut self, timestamp: &mut Timestamp, _meta: &mut Meta, _state: &ProcessingState<'_>, ) -> ProcessingResult
fn before_process<T>(
&mut self,
value: Option<&T>,
meta: &mut Meta,
state: &ProcessingState<'_>,
) -> Result<(), ProcessingAction>where
T: ProcessValue,
fn after_process<T>(
&mut self,
value: Option<&T>,
meta: &mut Meta,
state: &ProcessingState<'_>,
) -> Result<(), ProcessingAction>where
T: ProcessValue,
fn process_string( &mut self, value: &mut String, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_u64( &mut self, value: &mut u64, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_i64( &mut self, value: &mut i64, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_f64( &mut self, value: &mut f64, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_bool( &mut self, value: &mut bool, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_value( &mut self, value: &mut Value, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_array<T>(
&mut self,
value: &mut Vec<Annotated<T>>,
meta: &mut Meta,
state: &ProcessingState<'_>,
) -> Result<(), ProcessingAction>where
T: ProcessValue,
fn process_object<T>(
&mut self,
value: &mut BTreeMap<String, Annotated<T>>,
meta: &mut Meta,
state: &ProcessingState<'_>,
) -> Result<(), ProcessingAction>where
T: ProcessValue,
fn process_pairlist<T>(
&mut self,
value: &mut PairList<T>,
meta: &mut Meta,
state: &ProcessingState<'_>,
) -> Result<(), ProcessingAction>where
T: ProcessValue + AsPair,
fn process_values<T>(
&mut self,
value: &mut Values<T>,
meta: &mut Meta,
state: &ProcessingState<'_>,
) -> Result<(), ProcessingAction>where
T: ProcessValue,
fn process_replay( &mut self, value: &mut Replay, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_exception( &mut self, value: &mut Exception, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_raw_stacktrace( &mut self, value: &mut RawStacktrace, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_stacktrace( &mut self, value: &mut Stacktrace, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_frame( &mut self, value: &mut Frame, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_request( &mut self, value: &mut Request, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_user( &mut self, value: &mut User, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_client_sdk_info( &mut self, value: &mut ClientSdkInfo, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_debug_meta( &mut self, value: &mut DebugMeta, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_debug_image( &mut self, value: &mut DebugImage, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_geo( &mut self, value: &mut Geo, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_logentry( &mut self, value: &mut LogEntry, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_thread( &mut self, value: &mut Thread, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_context( &mut self, value: &mut Context, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_template_info( &mut self, value: &mut TemplateInfo, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_header_name( &mut self, value: &mut HeaderName, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_span( &mut self, value: &mut Span, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_trace_context( &mut self, value: &mut TraceContext, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_native_image_path( &mut self, value: &mut NativeImagePath, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_contexts( &mut self, value: &mut Contexts, meta: &mut Meta, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
fn process_other( &mut self, other: &mut BTreeMap<String, Annotated<Value>>, state: &ProcessingState<'_>, ) -> Result<(), ProcessingAction>
Auto Trait Implementations§
impl Freeze for ClockDriftProcessor
impl RefUnwindSafe for ClockDriftProcessor
impl Send for ClockDriftProcessor
impl Sync for ClockDriftProcessor
impl Unpin for ClockDriftProcessor
impl UnwindSafe for ClockDriftProcessor
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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