Struct otlp_embedded::State
source · pub struct State { /* private fields */ }
Expand description
In-memory state that maintains the most recent traces.
Old traces that are no longer updated or accessed will be evicted when the capacity is reached.
Implementations§
source§impl State
impl State
sourcepub fn new(recent: u32) -> StateRef
pub fn new(recent: u32) -> StateRef
Create a new State
with the given number of recent traces to keep.
Examples found in repository?
examples/basic.rs (line 5)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
async fn main() {
let state = State::new(100);
let state_clone = state.clone();
tokio::spawn(async {
axum::Server::bind(&"0.0.0.0:10188".parse().unwrap())
.serve(ui_app(state, "/").into_make_service())
.await
.unwrap();
});
tonic::transport::Server::builder()
.add_service(TraceServiceServer::new(TraceServiceImpl::new(state_clone)))
.serve("0.0.0.0:43177".parse().unwrap())
.await
.unwrap();
}
sourcepub fn get_by_id(&mut self, id: &[u8]) -> Option<Trace>
pub fn get_by_id(&mut self, id: &[u8]) -> Option<Trace>
Get a trace by its ID.
The trace will be promoted to the most recent.
sourcepub fn get_all_complete(&self) -> impl Iterator<Item = Trace> + '_
pub fn get_all_complete(&self) -> impl Iterator<Item = Trace> + '_
Get an iterator over all traces that are complete.
sourcepub fn get_all_services(&self) -> BTreeSet<&str>
pub fn get_all_services(&self) -> BTreeSet<&str>
Get a set of all services.
sourcepub fn get_operations(&self, service_name: &str) -> BTreeSet<&str>
pub fn get_operations(&self, service_name: &str) -> BTreeSet<&str>
Get a set of all operations for the given service.
Auto Trait Implementations§
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
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
Mutably borrows from an owned value. Read more
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request