Struct BetterStackConfig

Source
pub struct BetterStackConfig {
    pub ingesting_host: String,
    pub source_token: String,
    pub batch_size: usize,
    pub batch_timeout: Duration,
    pub max_retries: usize,
    pub initial_retry_delay: Duration,
    pub max_retry_delay: Duration,
    pub include_location: bool,
    pub include_spans: bool,
}
Expand description

Configuration for the Better Stack tracing layer.

This struct contains all the configuration options for sending logs to Better Stack. Use BetterStackConfig::builder to create a new configuration.

§Example

use std::time::Duration;
use tracing_better_stack::BetterStackConfig;

let config = BetterStackConfig::builder(
    "s1234567.us-east-9.betterstackdata.com",
    "source_token_here"
)
.batch_size(200)
.batch_timeout(Duration::from_secs(10))
.include_location(false)
.build();

Fields§

§ingesting_host: String

The ingesting host provided by Better Stack for your source.

This is the hostname where logs will be sent, without the protocol. Better Stack provides unique hosts for each source, typically in the format: s1234567.us-east-9.betterstackdata.com

You can find this in your Better Stack dashboard when viewing your source.

§source_token: String

The source token for authentication with Better Stack.

This token authenticates your application with Better Stack. It should be kept secret and not committed to version control. You can find this in your Better Stack dashboard when viewing your source.

§batch_size: usize

Maximum number of events to batch before sending.

Once this limit is reached, the batch will be sent immediately, even if the batch timeout hasn’t expired.

Default: 100

§batch_timeout: Duration

Maximum time to wait before sending a batch.

If this duration elapses and there are any events in the batch, they will be sent even if the batch size hasn’t been reached.

Default: 5 seconds

§max_retries: usize

Maximum number of retry attempts for failed requests.

When a request to Better Stack fails, the layer will retry with exponential backoff up to this many times.

Default: 3

§initial_retry_delay: Duration

Initial delay before the first retry attempt.

This delay will be doubled for each subsequent retry, up to max_retry_delay.

Default: 100ms

§max_retry_delay: Duration

Maximum delay between retry attempts.

The retry delay won’t exceed this value, even with exponential backoff.

Default: 10 seconds

§include_location: bool

Whether to include file and line location in log events.

When enabled, adds a location field to each log event containing the source file path and line number.

Default: true

§include_spans: bool

Whether to include span context in log events.

When enabled, adds a spans field to each log event containing information about the active spans and their fields.

Default: true

Implementations§

Source§

impl BetterStackConfig

Source

pub fn builder( ingesting_host: impl Into<String>, source_token: impl Into<String>, ) -> BetterStackConfigBuilder

Creates a new configuration builder with the required ingesting host and source token.

This is the recommended way to create a BetterStackConfig. The builder provides a fluent API for setting optional configuration values.

§Arguments
  • ingesting_host - The Better Stack ingesting host for your source
  • source_token - Your Better Stack source token for authentication
§Example
use tracing_better_stack::BetterStackConfig;

let config = BetterStackConfig::builder(
    "s1234567.us-east-9.betterstackdata.com",
    "your_source_token"
)
.batch_size(50)
.build();

Trait Implementations§

Source§

impl Clone for BetterStackConfig

Source§

fn clone(&self) -> BetterStackConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BetterStackConfig

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<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
Source§

impl<T> ErasedDestructor for T
where T: 'static,