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
impl BetterStackConfig
Sourcepub fn builder(
ingesting_host: impl Into<String>,
source_token: impl Into<String>,
) -> BetterStackConfigBuilder
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 sourcesource_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
impl Clone for BetterStackConfig
Source§fn clone(&self) -> BetterStackConfig
fn clone(&self) -> BetterStackConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more