Rust SDK: Configuration
Configuration Builder
Section titled “Configuration Builder”The AiresConfigBuilder is the entry point for all configuration. It uses a builder pattern with sensible defaults:
Options Reference
Section titled “Options Reference”Required Options
Section titled “Required Options”| Option | Type | Description |
|---|---|---|
service | String | Required. The service name identifies your application in all events. Examples: "workforce-api", "billing-worker", "auth-service". |
endpoint | String | Required. The collector’s gRPC endpoint. Examples: "http://localhost:4317", "https://collector.prod.internal:4317". |
Identity
Section titled “Identity”| Option | Type | Default | Description |
|---|---|---|---|
environment | String | "production" | Environment name. Set to "staging", "dev", "test", etc. Used for filtering events and preventing cross-environment pollution. |
Batching
Section titled “Batching”| Option | Type | Default | Description |
|---|---|---|---|
batch_size | usize | 256 | Maximum events per batch. When the buffer reaches this count, the batch is shipped immediately. Must be > 0. |
batch_timeout | Duration | 500ms | Maximum time to wait before shipping a partial batch. Even if batch_size hasn’t been reached, the batch is shipped after this interval. |
queue_capacity | usize | 8192 | Maximum events buffered in the channel between the application and the batch worker. Must be >= batch_size. If the queue is full, new events are dropped. |
flush_timeout | Duration | 5s | Maximum time to wait when flushing remaining events at shutdown. If the flush takes longer, remaining events are dropped. |
Transport
Section titled “Transport”| Option | Type | Default | Description |
|---|---|---|---|
tls | bool | true | Enable TLS for the gRPC connection. Set to false for local development (e.g. http://localhost:4317). |
api_key | Option<String> | None | API key for authenticated collector endpoints. Sent as gRPC metadata. |
Retries
Section titled “Retries”| Option | Type | Default | Description |
|---|---|---|---|
max_retries | u32 | 3 | Maximum retry attempts for a failed batch. After this many failures, the batch is dropped and a warning is logged via tracing. |
retry_backoff | Duration | 100ms | Base backoff duration between retries. The actual backoff is retry_backoff * attempt_number (linear backoff). |
Validation Rules
Section titled “Validation Rules”The builder validates configuration when .build() is called:
servicemust be set (returnsError::Configif missing)endpointmust be set (returnsError::Configif missing)batch_sizemust be > 0queue_capacitymust be >=batch_size
Tuning Guidelines
Section titled “Tuning Guidelines”High-Throughput Applications
Section titled “High-Throughput Applications”For services that emit millions of events per second:
Low-Latency Applications
Section titled “Low-Latency Applications”For services where observability overhead must be minimal:
Development
Section titled “Development”For local development with a local collector:
Environment Variable Pattern
Section titled “Environment Variable Pattern”The SDK doesn’t read environment variables directly, but here’s a common pattern:
Config Accessors
Section titled “Config Accessors”Once built, you can read configuration values: