pub struct Client<T: Sender> {
pub transmission: T,
/* private fields */
}
Expand description
Client represents an object that can create new builders and events and send them somewhere.
Fields§
§transmission: T
transmission mechanism for the client
Implementations§
Source§impl<T> Client<T>where
T: Sender,
impl<T> Client<T>where
T: Sender,
Sourcepub fn new(options: Options, transmission: T) -> Self
pub fn new(options: Options, transmission: T) -> Self
new creates a new Client with the provided Options and initialised Transmission.
Once populated, it auto starts the transmission background threads and is ready to send events.
Sourcepub fn add(&mut self, data: HashMap<String, Value>)
pub fn add(&mut self, data: HashMap<String, Value>)
add adds its data to the Client’s scope. It adds all fields in a struct or all keys in a map as individual Fields. These metrics will be inherited by all builders and events.
Sourcepub fn add_field(&mut self, name: &str, value: Value)
pub fn add_field(&mut self, name: &str, value: Value)
add_field adds a Field to the Client’s scope. This metric will be inherited by all builders and events.
Sourcepub fn add_dynamic_field(&mut self, name: &str, func: DynamicFieldFunc)
pub fn add_dynamic_field(&mut self, name: &str, func: DynamicFieldFunc)
add_dynamic_field takes a field name and a function that will generate values for that metric. The function is called once every time a new_event() is created and added as a field (with name as the key) to the newly created event.
Sourcepub fn close(self) -> Result<()>
pub fn close(self) -> Result<()>
close waits for all in-flight messages to be sent. You should call close() before app termination.
Sourcepub fn flush(&mut self) -> Result<()>
pub fn flush(&mut self) -> Result<()>
flush closes and reopens the Transmission, ensuring events are sent without waiting on the batch to be sent asyncronously. Generally, it is more efficient to rely on asyncronous batches than to call Flush, but certain scenarios may require Flush if asynchronous sends are not guaranteed to run (i.e. running in AWS Lambda) Flush is not thread safe - use it only when you are sure that no other parts of your program are calling Send
Sourcepub fn new_builder(&self) -> Builder
pub fn new_builder(&self) -> Builder
new_builder creates a new event builder. The builder inherits any Dynamic or Static Fields present in the Client’s scope.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Client<T>where
T: Freeze,
impl<T> RefUnwindSafe for Client<T>where
T: RefUnwindSafe,
impl<T> Send for Client<T>where
T: Send,
impl<T> Sync for Client<T>where
T: Sync,
impl<T> Unpin for Client<T>where
T: Unpin,
impl<T> UnwindSafe for Client<T>where
T: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)