pub struct TelemetryConfig {
pub service_name: String,
pub service_version: String,
pub log_level: String,
pub json_logs: bool,
pub stderr_output: bool,
pub otlp_endpoint: Option<String>,
pub otlp_protocol: OtlpProtocol,
pub sampling_ratio: f64,
pub export_timeout: Duration,
pub prometheus_port: Option<u16>,
pub prometheus_path: String,
pub resource_attributes: Vec<(String, String)>,
}Expand description
Telemetry configuration
Use TelemetryConfigBuilder for ergonomic configuration construction.
§Example
use turbomcp_telemetry::TelemetryConfig;
let config = TelemetryConfig::builder()
.service_name("my-mcp-server")
.service_version("1.0.0")
.log_level("info,turbomcp=debug")
.build();Fields§
§service_name: StringService name for telemetry identification
service_version: StringService version
log_level: StringLog level filter (e.g., “info”, “debug”, “info,turbomcp=debug”)
json_logs: boolEnable JSON-formatted log output
stderr_output: boolOutput logs to stderr (required for STDIO transport)
otlp_endpoint: Option<String>Available on crate feature
opentelemetry only.OpenTelemetry OTLP endpoint (e.g., “http://localhost:4317”)
otlp_protocol: OtlpProtocolAvailable on crate feature
opentelemetry only.OTLP protocol (grpc or http)
sampling_ratio: f64Available on crate feature
opentelemetry only.Trace sampling ratio (0.0 to 1.0)
export_timeout: DurationAvailable on crate feature
opentelemetry only.Export timeout
prometheus_port: Option<u16>Available on crate feature
prometheus only.Prometheus metrics endpoint port
prometheus_path: StringAvailable on crate feature
prometheus only.Prometheus metrics endpoint path
resource_attributes: Vec<(String, String)>Additional resource attributes
Implementations§
Source§impl TelemetryConfig
impl TelemetryConfig
Sourcepub fn builder() -> TelemetryConfigBuilder
pub fn builder() -> TelemetryConfigBuilder
Create a new configuration builder
Sourcepub fn init(self) -> Result<TelemetryGuard, TelemetryError>
pub fn init(self) -> Result<TelemetryGuard, TelemetryError>
Initialize telemetry with this configuration
Returns a guard that ensures proper cleanup on drop.
Trait Implementations§
Source§impl Clone for TelemetryConfig
impl Clone for TelemetryConfig
Source§fn clone(&self) -> TelemetryConfig
fn clone(&self) -> TelemetryConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TelemetryConfig
impl Debug for TelemetryConfig
Auto Trait Implementations§
impl Freeze for TelemetryConfig
impl RefUnwindSafe for TelemetryConfig
impl Send for TelemetryConfig
impl Sync for TelemetryConfig
impl Unpin for TelemetryConfig
impl UnsafeUnpin for TelemetryConfig
impl UnwindSafe for TelemetryConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more