Skip to main content

Config

Struct Config 

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

Settings for the Flare client.

Applications usually start with the flareapp::config! macro, which also sets the name and version of the application.

§Examples

let config = flareapp_core::Config::new()
    .api_key("your-api-key")
    .environment("production");

Implementations§

Source§

impl Config

Source

pub fn new() -> Self

Creates a config with the default settings, filled in from these environment variables, or from the .env file, when they are set:

VariableSetting
FLARE_KEYConfig::api_key
FLARE_ENVIRONMENTConfig::environment
FLARE_TRACES_SAMPLE_RATEConfig::traces_sample_rate, like 0.1
FLARE_ENDPOINTConfig::endpoint
FLARE_DEBUGConfig::debug: true or 1
OTEL_EXPORTER_OTLP_PROTOCOLConfig::otlp_protocol: http/protobuf or http/json

The .env file is the file in the current folder. The Flare client does not search parent folders. The Flare client only reads the file. The Flare client does not change the environment of your app. Reading the .env file needs the dotenv feature of the flareapp crate, which is on by default.

An environment variable wins over the same variable in the .env file. Settings you make in code afterwards win over both.

Source

pub fn api_key<S: Into<String>>(self, api_key: S) -> Self

Sets the API key of your Flare project. An empty key disables the Flare client. Spaces and line breaks around the key are removed.

Logs and traces need the private API key of your project.

Source

pub fn endpoint<S: Into<String>>(self, endpoint: S) -> Self

Sets the URL that data is sent to. The default is https://ingress.flareapp.io.

Logs and traces can go to any server that accepts OTLP over HTTP, for example a local OpenTelemetry Collector on http://localhost:4318. The config removes spaces and line breaks around the URL. The config also removes a slash at the end. The config ignores a blank URL, so the endpoint stays the same.

Source

pub fn otlp_protocol(self, protocol: OtlpProtocol) -> Self

Sets how logs and traces are encoded. The default is OtlpProtocol::HttpProtobuf.

Use OtlpProtocol::HttpJson when you want to read the requests, or for a server that only accepts OTLP/JSON. Error reports are always sent as JSON.

Source

pub fn service_name<S: Into<String>>(self, name: S) -> Self

Sets the name of your application, sent as service.name.

Without a name, Flare receives unknown_service:<name of the executable>.

Source

pub fn service_version<S: Into<String>>(self, version: S) -> Self

Sets the version of your application, sent as service.version.

Source

pub fn git_hash<S: Into<String>>(self, hash: S) -> Self

Sets the git commit of the code that runs, sent as git.hash. Flare shows the first 7 characters as the version of your application. A blank hash removes the hash.

flareapp::config! sets the hash when you build the app with FLARE_GIT_HASH, or on a CI that gives the commit, like GitHub Actions.

Without a hash, the Flare client runs git in the Config::application_path when it starts, if that folder exists. The Flare client then also sends the branch and the newest tag.

Source

pub fn environment<S: Into<String>>(self, environment: S) -> Self

Sets the environment your application runs in, like production or staging. The config removes spaces and line breaks around the name. A blank name removes the environment.

Source

pub fn debug(self, debug: bool) -> Self

Prints what the Flare client does to stderr, like sent requests and errors. Turn this on while you set up the Flare client.

Source

pub fn timeout(self, timeout: Duration) -> Self

Sets the longest time that one HTTP request to Flare can take. The default is 10 seconds.

Only the default HTTP client uses this setting. A transport that you set with Config::transport uses its own timeouts.

Source

pub fn shutdown_timeout(self, timeout: Duration) -> Self

Sets how long the Guard waits for queued data to be sent when it is dropped. The default is 2 seconds.

Source

pub fn queue_capacity(self, capacity: usize) -> Self

Sets how many records can wait in the queue. The default is 1024. A value of 0 becomes 1.

When the queue is full, new records are dropped, so your application never waits for Flare.

The worker thread also keeps at most this many records of each kind while they wait to be sent. When that limit is reached, the oldest record is dropped.

Source

pub fn batch_size(self, size: usize) -> Self

Sets the maximum number of log records, or of traces, sent in one request. The default is 100. A value of 0 becomes 1.

A trace is never split over two requests, so one request can hold more spans than this number. Error reports are always sent one per request.

Source

pub fn batch_interval(self, interval: Duration) -> Self

Sets how long logs and spans wait before they are sent, so they can be sent together in one request. The default is 5 seconds.

Source

pub fn transport<T: Transport>(self, transport: T) -> Self

Replaces the HTTP client that sends data to Flare.

Use this to send data with your own HTTP client, or to capture requests in tests. See Transport.

Source

pub fn before_send<F>(self, hook: F) -> Self
where F: Fn(&mut Report) -> bool + Send + Sync + 'static,

Runs hook before each report is sent. Return false to drop the report.

Use this hook to remove sensitive data, or to skip errors that you do not want in Flare.

§Examples
let config = flareapp_core::Config::new().before_send(|report| {
    report.exception_class() != "my_app::NotFound"
});
Source

pub fn app_crate<S: Into<String>>(self, name: S) -> Self

Marks the frames of a crate as application code. Write the crate name as in your Cargo.toml, like my-billing, or with underscores, like my_billing. Both spellings work. The macro flareapp::config! adds your own crate.

Source

pub fn application_path<S: Into<String>>(self, path: S) -> Self

Sets the root folder of your application. Flare uses it to show shorter file paths. flareapp::config! sets it to the folder of your Cargo.toml.

Source

pub fn workspace_root<S: Into<String>>(self, path: S) -> Self

Sets the root folder of your Cargo workspace, or the folder of your Cargo.toml when there is no workspace. flareapp::config! finds it.

Rust gives the file of a report location, like the line of a panic, relative to this folder, like crates/app/src/main.rs. The Flare client puts this folder in front of that path, so the path matches the rest of the stack trace. When you build with --remap-path-prefix, set workspace_root to the new prefix.

Source

pub fn framework<N: Into<String>>( self, name: N, version: Option<String>, ) -> Self

Sets the framework the application is built on, sent as flare.framework.name and flare.framework.version. Framework integrations set this value. Use a lowercase name.

Source

pub fn traces_sample_rate(self, rate: f64) -> Self

Turns tracing on and sets the share of traces to send: from 0.0 (none, the default) to 1.0 (all). Flare’s PHP client uses 0.1. A value below 0.0 becomes 0.0, a value above 1.0 becomes 1.0, and NaN becomes 0.0.

The Flare client decides once per trace, at the first span of the trace. When an incoming request has a traceparent header, the decision in that header wins.

Source

pub fn censor_client_ips(self, censor: bool) -> Self

Stops sending the IP address of the client that made a request, as client.address. By default, the web integrations send it, like Flare’s PHP client.

Source

pub fn default_transport<T, F>(self, make: F) -> Self
where T: Transport, F: FnOnce(Duration) -> T,

Sets the transport that make creates, but only when no transport is set.

make gets the request timeout from Config::timeout. The flareapp crate uses this to set its default HTTP client.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Config

§

impl !UnwindSafe for Config

§

impl Forget for Config

§

impl Freeze for Config
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<dyn Transport> is !null: Freeze, PhantomData<ArcInner<dyn Transport>>: Freeze, *const ArcInner<dyn Fn(&mut Report) -> bool + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&mut Report) -> bool + Sync + Send>>: Freeze, PhantomData<String>: Freeze,

§

impl Move for Config

§

impl Send for Config
where RawVecInner: Send, Arc<dyn Transport>: Send, Arc<dyn Fn(&mut Report) -> bool + Sync + Send>: Send,

§

impl Sync for Config
where RawVecInner: Sync, Arc<dyn Transport>: Sync, Arc<dyn Fn(&mut Report) -> bool + Sync + Send>: Sync,

§

impl Unpin for Config
where *const u8 is !null: Unpin, Arc<dyn Transport>: Unpin, Arc<dyn Fn(&mut Report) -> bool + Sync + Send>: Unpin,

§

impl UnsafeUnpin for Config
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<dyn Transport> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Transport>>: UnsafeUnpin, *const ArcInner<dyn Fn(&mut Report) -> bool + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&mut Report) -> bool + Sync + Send>>: UnsafeUnpin, PhantomData<String>: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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