pub struct StreamAttempt { /* private fields */ }Expand description
Per-attempt trace state for one OpenAI-compatible request: the optional tracer plus this attempt’s monotonic clock. Every method is a no-op when tracing is disabled; nothing here can fail the request.
Implementations§
Source§impl StreamAttempt
impl StreamAttempt
Sourcepub fn new(tracer: Option<RequestTracer>) -> Self
pub fn new(tracer: Option<RequestTracer>) -> Self
Start the first attempt’s clock. Call immediately before the send.
Sourcepub fn restart_clock(&mut self)
pub fn restart_clock(&mut self)
Restart the per-attempt clock (retry loops call this right before each re-send — retry clocks reset per attempt).
Sourcepub fn request_id(&self) -> Option<&TraceId>
pub fn request_id(&self) -> Option<&TraceId>
The trace request ID, when a tracer began (for content-capture
correlation). None when tracing is disabled for this request.
pub fn mark_headers(&mut self)
pub fn mark_first_byte(&mut self)
pub fn mark_first_model_event(&mut self)
Sourcepub fn attempt_failed(
&mut self,
class: RetryClass,
delay: Duration,
http_status: Option<u16>,
provider_request_id: Option<TraceId>,
code: &str,
)
pub fn attempt_failed( &mut self, class: RetryClass, delay: Duration, http_status: Option<u16>, provider_request_id: Option<TraceId>, code: &str, )
Record a failed attempt that WILL be retried (one record per actual
send). code must be a static literal or http_<status>.
Sourcepub fn finish_success(
&mut self,
http_status: Option<u16>,
provider_request_id: Option<TraceId>,
stop_reason: Option<StopReason>,
usage: Option<UsageMeta>,
)
pub fn finish_success( &mut self, http_status: Option<u16>, provider_request_id: Option<TraceId>, stop_reason: Option<StopReason>, usage: Option<UsageMeta>, )
Final record: request completed. Subsequent finish calls are no-ops (the tracer is taken), so error paths can never double-emit.
Auto Trait Implementations§
impl !RefUnwindSafe for StreamAttempt
impl !UnwindSafe for StreamAttempt
impl Freeze for StreamAttempt
impl Send for StreamAttempt
impl Sync for StreamAttempt
impl Unpin for StreamAttempt
impl UnsafeUnpin for StreamAttempt
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.