pub struct StandardLoki {}Expand description
The standard implementation of the Loki transport logic.
StandardLokiService provides the baseline behavior for the logging pipeline,
using the standard batching and retry mechanisms defined in the LokiService
default trait methods.
§Behavior
- Transport: Uses the
reqwestblocking client to push JSON payloads. - Fallback: Inherits the default
LokiFallbackbehavior, which redirects failed logs to the system’s standard error and output streams.
This struct is stateless, acting primarily as a marker to satisfy the trait
requirements of the LokiLogger.
Trait Implementations§
Source§impl Fallback for StandardLoki
impl Fallback for StandardLoki
Source§fn fallback(&self, error: &ServiceError, msg: &Message)
fn fallback(&self, error: &ServiceError, msg: &Message)
Handles the ultimate delivery failure for a log message.
This method is the “safety net” of the logging pipeline. It is invoked when a message cannot be sent to Loki after exhausting all retry attempts or encountering a non-recoverable error (like a 400 Bad Request).
§Default Behavior
The default implementation performs a Best-Effort recovery:
- Formats the failure reason (HTTP status or Network error) to
stderr. - Prints the original log content to
stdoutwith its timestamp, level, and payload.
This ensures that even in a total network collapse, the logs are captured by the system’s standard output streams (useful for Docker/K8s logs collectors).
§Thread Safety
This is called from the background worker thread. Any custom implementation must be non-blocking and thread-safe to avoid stalling the entire logging pipeline.
Source§impl Loki for StandardLoki
impl Loki for StandardLoki
Source§fn work(&self, receiver: Receiver<LokiMessage>, data: Arc<LokiData>)
fn work(&self, receiver: Receiver<LokiMessage>, data: Arc<LokiData>)
Source§fn work_batch(
&self,
level: &str,
batch: &mut Vec<LokiMessage>,
data: &Arc<LokiData>,
) -> Result<Response, ServiceError>
fn work_batch( &self, level: &str, batch: &mut Vec<LokiMessage>, data: &Arc<LokiData>, ) -> Result<Response, ServiceError>
Auto Trait Implementations§
impl Freeze for StandardLoki
impl RefUnwindSafe for StandardLoki
impl Send for StandardLoki
impl Sync for StandardLoki
impl Unpin for StandardLoki
impl UnwindSafe for StandardLoki
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