Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

Hands telemetry to the worker thread and controls the thread’s lifetime.

The client puts records on a queue. The worker thread takes them off the queue, groups them into batches and sends them to Flare.

Applications use init, which creates the global client. Integrations get the global client with current.

Implementations§

Source§

impl Client

Source

pub fn start(config: Config) -> Result<Self, StartError>

Starts the worker thread and returns a client that sends to it.

With Config::debug on, this function first prints the warnings about the environment variables and the .env file. The warnings also print when the client does not start, for example without an API key.

§Errors

Returns a StartError when the Flare client cannot send anything: when no API key is set, when no transport is set, or when the operating system does not start the worker thread.

Source

pub fn send_log<S: Into<Cow<'static, str>>>(&self, target: S, record: LogRecord)

Queues a log record for sending. Returns right away.

target is the tracing or log target that wrote the record, like my_app::billing. It becomes the name of the record’s instrumentation scope, which Flare shows as the target of the log.

Source

pub fn send_trace(&self, spans: Vec<Span>)

Queues all finished spans of one trace for sending. Returns right away.

Flare drops a span when its parent is not in the same request, so the spans of a trace always go out together.

Source

pub fn traces_sample_rate(&self) -> f64

Returns the share of traces to send, from 0.0 (none) to 1.0 (all).

Source

pub fn set_framework<N: Into<String>>(&self, name: N, version: Option<String>)

Adds the framework the app runs on to the resource, as flare.framework.name and flare.framework.version. Flare shows it with every error, log and trace that is sent after this call.

Web integrations call this when they detect their framework. Only the first call counts, and a framework from Config::framework wins.

Source

pub fn censors_client_ips(&self) -> bool

Returns true when the IP address of a client must not be sent. See Config::censor_client_ips.

Source

pub fn send_report(&self, report: Report) -> Option<ReportId>

Queues an error report for sending. Returns right away.

Adds the current scope first, then runs the before_send hook. Returns the tracking id. Returns None when the hook dropped the report. Also returns None when the queue was full or the worker thread had stopped, because the client then did not queue the report.

Source

pub fn send_report_and_wait(&self, report: Report) -> Option<ReportId>

Queues an error report and waits until it is sent, or until the shutdown timeout has passed. When the queue is full, this function waits for room and does not drop the report.

Returns None when the before_send hook dropped the report, or when the queue had no room before the timeout.

The panic integration uses this function, because the process can end right after a panic.

Source

pub fn app_crates(&self) -> &[String]

Returns the crates whose frames count as application code.

Source

pub fn flush(&self, timeout: Duration) -> bool

Waits until the worker thread has sent everything in the queue, or until timeout has passed. Returns true when nothing is left to send.

Data that Flare refused, or that still failed after all retries, is dropped and also counts as done. When the worker thread must wait longer than timeout before the next retry, for example because of a Retry-After header, this function returns false right away.

Trait Implementations§

Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl !UnwindSafe for Client

§

impl Forget for Client

§

impl Move for Client

§

impl Send for Client
where SyncSender<Message>: Send, Arc<dyn Fn(&mut Report) -> bool + Sync + Send>: Send, RawVecInner: Send, Atomic<bool>: Send, Mutex<Option<WorkerThread>>: Send,

§

impl Sync for Client
where Sender<Message>: Sync, Arc<dyn Fn(&mut Report) -> bool + Sync + Send>: Sync, RawVecInner: Sync, Atomic<bool>: Sync, Mutex<Option<WorkerThread>>: Sync,

§

impl Unpin for Client
where *mut Counter<Channel<Message>>: Unpin, *mut Counter<Channel<Message>>: Unpin, *mut Counter<Channel<Message>>: Unpin, Arc<dyn Fn(&mut Report) -> bool + Sync + Send>: Unpin, *const u8 is !null: Unpin, Align1<u8>: Unpin, Align4<u32>: Unpin, Arc<Inner, System>: Unpin, Arc<Packet<'static, ()>>: Unpin, *mut Counter<Channel<()>>: Unpin, *mut Counter<Channel<()>>: Unpin, *mut Counter<Channel<()>>: Unpin,

§

impl UnsafeUnpin for Client
where *mut Counter<Channel<Message>>: UnsafeUnpin, *mut Counter<Channel<Message>>: UnsafeUnpin, *mut Counter<Channel<Message>>: UnsafeUnpin, *const ArcInner<dyn Fn(&mut Report) -> bool + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&mut Report) -> bool + Sync + Send>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<String>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, Align1<u8>: UnsafeUnpin, Align4<u32>: UnsafeUnpin, *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin, *const ArcInner<Packet<'static, ()>> is !null: UnsafeUnpin, PhantomData<ArcInner<Packet<'static, ()>>>: UnsafeUnpin, *mut Counter<Channel<()>>: UnsafeUnpin, *mut Counter<Channel<()>>: UnsafeUnpin, *mut Counter<Channel<()>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more