Skip to main content

OtelConfig

Struct OtelConfig 

Source
pub struct OtelConfig {
Show 47 fields pub endpoint: String, pub trace_endpoint: Option<String>, pub metric_endpoint: Option<String>, pub log_endpoint: Option<String>, pub endpoint_headers: Option<String>, pub trace_headers: Option<String>, pub metric_headers: Option<String>, pub log_headers: Option<String>, pub endpoint_timeout_millis: Option<u64>, pub trace_timeout_millis: Option<u64>, pub metric_timeout_millis: Option<u64>, pub log_timeout_millis: Option<u64>, pub tls_ca_file: Option<String>, pub profiling_endpoint: Option<String>, pub traces_export_enabled: Option<bool>, pub metrics_export_enabled: Option<bool>, pub logs_export_enabled: Option<bool>, pub profiling_export_enabled: Option<bool>, pub use_stdout: Option<bool>, pub sample_ratio: Option<f64>, pub meter_interval: Option<u64>, pub service_name: Option<String>, pub service_version: Option<String>, pub environment: Option<String>, pub logger_level: Option<String>, pub log_stdout_enabled: Option<bool>, pub log_directory: Option<String>, pub log_filename: Option<String>, pub log_rotation_time: Option<String>, pub log_keep_files: Option<usize>, pub log_max_total_size_bytes: Option<u64>, pub log_max_single_file_size_bytes: Option<u64>, pub log_compress_old_files: Option<bool>, pub log_gzip_compression_level: Option<u32>, pub log_compression_algorithm: Option<String>, pub log_parallel_compress: Option<bool>, pub log_parallel_workers: Option<usize>, pub log_zstd_compression_level: Option<i32>, pub log_zstd_fallback_to_gzip: Option<bool>, pub log_zstd_workers: Option<usize>, pub log_compressed_file_retention_days: Option<u64>, pub log_exclude_patterns: Option<String>, pub log_delete_empty_files: Option<bool>, pub log_min_file_age_seconds: Option<u64>, pub log_cleanup_interval_seconds: Option<u64>, pub log_dry_run: Option<bool>, pub log_match_mode: Option<String>,
}
Expand description

Full observability configuration used by all telemetry backends.

Fields are grouped into three logical sections:

§OpenTelemetry / OTLP export

Controls whether and where traces, metrics, and logs are exported over the wire using the OTLP/HTTP protocol.

§Local logging

Controls the rolling-file appender: directory, filename, rotation policy, and the number of files to retain.

§Log cleanup

Controls the background cleanup task: size limits, compression, retention of compressed archives, exclusion patterns, and dry-run mode.

§Design Notes

  • All fields are Option<T> to allow partial configuration via environment variables with sensible defaults provided by constants in rustfs-config.
  • log_keep_files is used to derive the rolling-appender’s upper bound on retained files (if enabled) and to set the cleaner’s retained-file ceiling.

§Example

use rustfs_obs::OtelConfig;

// Build from environment variables (typical production usage).
let config = OtelConfig::new();

// Build with an explicit OTLP endpoint.
let config = OtelConfig::extract_otel_config_from_env(
    Some("http://otel-collector:4318".to_string())
);

// Compression related env mapping examples:
// RUSTFS_OBS_LOG_COMPRESSION_ALGORITHM=zstd
// RUSTFS_OBS_LOG_PARALLEL_COMPRESS=true
// RUSTFS_OBS_LOG_PARALLEL_WORKERS=6

Fields§

§endpoint: String

Root OTLP/HTTP endpoint (e.g. http://otel-collector:4318). Per-signal endpoints below take precedence when set.

§trace_endpoint: Option<String>

Dedicated trace endpoint; overrides endpoint + /v1/traces fallback.

§metric_endpoint: Option<String>

Dedicated metrics endpoint; overrides endpoint + /v1/metrics fallback.

§log_endpoint: Option<String>

Dedicated log endpoint; overrides endpoint + /v1/logs fallback.

§endpoint_headers: Option<String>

Headers applied to all OTLP signals when using HTTP exporter. Format: comma-separated key=value pairs with URL-encoded values, for example: Authorization=Bearer%20abc%20123,X-Scope-OrgID=my-tenant. URL-encode reserved characters in values such as spaces, commas, and =.

§trace_headers: Option<String>

Additional headers for traces; merged on top of endpoint_headers. Uses the same comma-separated key=value format with URL-encoded values.

§metric_headers: Option<String>

Additional headers for metrics; merged on top of endpoint_headers. Uses the same comma-separated key=value format with URL-encoded values.

§log_headers: Option<String>

Additional headers for logs; merged on top of endpoint_headers. Uses the same comma-separated key=value format with URL-encoded values.

§endpoint_timeout_millis: Option<u64>

Timeout (milliseconds) for all OTLP HTTP exports.

§trace_timeout_millis: Option<u64>

Timeout (milliseconds) for trace OTLP HTTP export.

§metric_timeout_millis: Option<u64>

Timeout (milliseconds) for metrics OTLP HTTP export.

§log_timeout_millis: Option<u64>

Timeout (milliseconds) for log OTLP HTTP export.

§tls_ca_file: Option<String>

Absolute path to a PEM bundle whose certificates are added to the system trust roots used by OTLP/HTTP exporters.

§profiling_endpoint: Option<String>

Dedicated profiling endpoint.

§traces_export_enabled: Option<bool>

Whether to export distributed traces (default: true).

§metrics_export_enabled: Option<bool>

Whether to export metrics (default: true).

§logs_export_enabled: Option<bool>

Whether to export logs via OTLP (default: true).

§profiling_export_enabled: Option<bool>

Whether to export profiles via pyroscope (default: true).

§use_stdout: Option<bool>

[OTLP-only] Mirror all signals to stdout in addition to OTLP export. Only applies when an OTLP endpoint is configured.

§sample_ratio: Option<f64>

Fraction of traces to sample, 0.0–1.0 (default: 1.0).

§meter_interval: Option<u64>

Metrics export interval in seconds (default: 30).

§service_name: Option<String>

OTel service.name attribute (default: APP_NAME).

§service_version: Option<String>

OTel service.version attribute (default: SERVICE_VERSION).

§environment: Option<String>

Deployment environment tag, e.g. production or development.

§logger_level: Option<String>

Minimum log level directive (default: error). Respects RUST_LOG syntax when set via environment.

§log_stdout_enabled: Option<bool>

When true, a stdout JSON layer is always attached regardless of the active backend (default: false in production, true otherwise).

§log_directory: Option<String>

Directory where rolling log files are written. When absent or empty, logging falls back to stdout-only mode.

§log_filename: Option<String>

Base name for log files (without date suffix), e.g. rustfs. Used for both rolling-appender naming and cleanup scanning.

§log_rotation_time: Option<String>

Rotation time granularity: "minutely", "hourly", or "daily" (default: "hourly"; any unrecognized value falls back to "daily").

§log_keep_files: Option<usize>

Number of rolling log files to retain (default: 30). Used by both the rolling-appender (as a loose upper bound) and the background cleaner (as the minimum retention count).

§log_max_total_size_bytes: Option<u64>

Hard ceiling on the total size (bytes) of all log files (default: 2 GiB).

§log_max_single_file_size_bytes: Option<u64>

Per-file size ceiling (bytes); 0 means unlimited (default: 0).

§log_compress_old_files: Option<bool>

Compress eligible files with gzip before deletion (default: true).

§log_gzip_compression_level: Option<u32>

Gzip compression level 1–9 (default: 6).

§log_compression_algorithm: Option<String>

Compression algorithm: gzip or zstd (default: zstd).

§log_parallel_compress: Option<bool>

Enable crossbeam work-stealing parallel compression (default: true).

§log_parallel_workers: Option<usize>

Worker count for parallel compression (default: 6).

§log_zstd_compression_level: Option<i32>

Zstd compression level 1–21 (default: 8).

§log_zstd_fallback_to_gzip: Option<bool>

Fallback to gzip when zstd compression fails (default: true).

§log_zstd_workers: Option<usize>

Internal zstdmt workers per job (default: 1).

§log_compressed_file_retention_days: Option<u64>

Delete compressed archives older than this many days; 0 = keep forever (default: 30).

§log_exclude_patterns: Option<String>

Comma-separated glob patterns for files that must never be cleaned up.

§log_delete_empty_files: Option<bool>

Delete zero-byte log files during cleanup (default: true).

§log_min_file_age_seconds: Option<u64>

A file younger than this many seconds is never touched (default: 3600).

§log_cleanup_interval_seconds: Option<u64>

How often the background cleanup task runs, in seconds (default: 1800).

§log_dry_run: Option<bool>

Log what would be deleted without actually removing anything (default: false).

§log_match_mode: Option<String>

File matching mode: “prefix” or “suffix” (default: “suffix”).

Implementations§

Source§

impl OtelConfig

Source

pub fn extract_otel_config_from_env(endpoint: Option<String>) -> OtelConfig

Build an OtelConfig from environment variables.

The optional endpoint argument sets the root OTLP endpoint. If it is None or an empty string the value is read from the RUSTFS_OBS_ENDPOINT environment variable instead.

When no endpoint is configured at all, use_stdout is forced to true so that logs are still visible during development.

§Example
use rustfs_obs::OtelConfig;

// Read everything from env vars.
let config = OtelConfig::extract_otel_config_from_env(None);

// Override the endpoint programmatically.
let config = OtelConfig::extract_otel_config_from_env(
    Some("http://localhost:4318".to_string())
);
Source

pub fn new() -> Self

Create a new OtelConfig populated entirely from environment variables.

Equivalent to OtelConfig::extract_otel_config_from_env(None).

§Example
use rustfs_obs::OtelConfig;
let config = OtelConfig::new();

Trait Implementations§

Source§

impl Clone for OtelConfig

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 OtelConfig

Source§

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

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

impl Default for OtelConfig

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for OtelConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for OtelConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CompatExt for T

Source§

fn compat(self) -> Compat<T> ⓘ
where T: Sized,

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T> ⓘ

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T> ⓘ

Applies the Compat adapter by mutable reference. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromExt for T

Source§

fn from_<T>(t: T) -> Self
where Self: From<T>,

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoExt for T

Source§

fn into_<T>(self) -> T
where Self: Into<T>,

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PluginEvent for T
where T: Send + Sync + Clone + Serialize + DeserializeOwned + 'static,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> TryFromExt for T

Source§

fn try_from_<T>(t: T) -> Result<Self, Self::Error>
where Self: TryFrom<T>,

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> TryIntoExt for T

Source§

fn try_into_<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

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