pub struct BetterStackConfigBuilder { /* private fields */ }
Expand description
Builder for creating a BetterStackConfig
with a fluent API.
This builder is created via BetterStackConfig::builder
and provides
methods to customize the configuration before building the final config.
§Example
use std::time::Duration;
use tracing_better_stack::BetterStackConfig;
let config = BetterStackConfig::builder(
"s1234567.us-east-9.betterstackdata.com",
"source_token"
)
.batch_size(200)
.batch_timeout(Duration::from_secs(10))
.max_retries(5)
.include_location(false)
.build();
Implementations§
Source§impl BetterStackConfigBuilder
impl BetterStackConfigBuilder
Sourcepub fn new(
ingesting_host: impl Into<String>,
source_token: impl Into<String>,
) -> Self
pub fn new( ingesting_host: impl Into<String>, source_token: impl Into<String>, ) -> Self
Creates a new builder with the required ingesting host and source token.
This method is typically not called directly. Use BetterStackConfig::builder
instead.
§Arguments
ingesting_host
- The Better Stack ingesting host for your sourcesource_token
- Your Better Stack source token for authentication
Sourcepub fn batch_size(self, size: usize) -> Self
pub fn batch_size(self, size: usize) -> Self
Sets the maximum number of events to batch before sending.
Once this limit is reached, the batch will be sent immediately.
Default: 100
§Example
let config = BetterStackConfig::builder("s1234567.us-east-9.betterstackdata.com", "your-source-token")
.batch_size(200)
.build();
Sourcepub fn batch_timeout(self, timeout: Duration) -> Self
pub fn batch_timeout(self, timeout: Duration) -> Self
Sets the 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
§Example
let config = BetterStackConfig::builder("s1234567.us-east-9.betterstackdata.com", "your-source-token")
.batch_timeout(Duration::from_secs(10))
.build();
Sourcepub fn max_retries(self, retries: usize) -> Self
pub fn max_retries(self, retries: usize) -> Self
Sets the maximum number of retry attempts for failed requests.
When a request fails, the layer will retry with exponential backoff.
Default: 3
§Example
let config = BetterStackConfig::builder("s1234567.us-east-9.betterstackdata.com", "your-source-token")
.max_retries(5)
.build();
Sourcepub fn initial_retry_delay(self, delay: Duration) -> Self
pub fn initial_retry_delay(self, delay: Duration) -> Self
Sets the initial delay before the first retry attempt.
This delay will be doubled for each subsequent retry.
Default: 100ms
§Example
let config = BetterStackConfig::builder("s1234567.us-east-9.betterstackdata.com", "your-source-token")
.initial_retry_delay(Duration::from_millis(200))
.build();
Sourcepub fn max_retry_delay(self, delay: Duration) -> Self
pub fn max_retry_delay(self, delay: Duration) -> Self
Sets the maximum delay between retry attempts.
The retry delay won’t exceed this value, even with exponential backoff.
Default: 10 seconds
§Example
let config = BetterStackConfig::builder("s1234567.us-east-9.betterstackdata.com", "your-source-token")
.max_retry_delay(Duration::from_secs(30))
.build();
Sourcepub fn include_location(self, include: bool) -> Self
pub fn include_location(self, include: bool) -> Self
Sets whether to include file and line location in log events.
When enabled, adds a location
field to each log event.
Default: true
§Example
let config = BetterStackConfig::builder("s1234567.us-east-9.betterstackdata.com", "your-source-token")
.include_location(false)
.build();
Sourcepub fn include_spans(self, include: bool) -> Self
pub fn include_spans(self, include: bool) -> Self
Sets whether to include span context in log events.
When enabled, adds a spans
field to each log event with active span information.
Default: true
§Example
let config = BetterStackConfig::builder("s1234567.us-east-9.betterstackdata.com", "your-source-token")
.include_spans(false)
.build();
Sourcepub fn build(self) -> BetterStackConfig
pub fn build(self) -> BetterStackConfig
Builds the final BetterStackConfig
with all the configured options.
§Example
let config = BetterStackConfig::builder("s1234567.us-east-9.betterstackdata.com", "your-source-token")
.batch_size(200)
.build(); // Returns the final BetterStackConfig