pub struct TelemetryConfig {
pub logging_enabled: bool,
pub log_filter: String,
pub json_logs: bool,
pub metrics_enabled: bool,
pub metrics_addr: Option<String>,
pub otel_traces: bool,
pub otel_metrics: bool,
pub otel_service_name: String,
pub otel_endpoint: Option<String>,
pub otel_gcp_project: Option<String>,
}Expand description
Telemetry configuration.
Fields§
§logging_enabled: boolEnable structured logging. Installing the subscriber requires the
tracing-subscriber crate feature; without it this flag is inert.
log_filter: StringLog level filter (e.g., “info”, “debug”, “gemini_genai_rs=debug”).
json_logs: boolUse JSON format for logs (production). If false, uses pretty format (development).
metrics_enabled: boolEnable Prometheus metrics endpoint.
metrics_addr: Option<String>Prometheus listen address (e.g., “0.0.0.0:9090”).
otel_traces: boolEnable OTel trace export (requires otel-otlp or otel-gcp feature).
otel_metrics: boolEnable OTel metrics export (requires otel-otlp or otel-gcp feature).
otel_service_name: StringOTel service name for resource identification.
otel_endpoint: Option<String>OTLP collector endpoint (e.g. http://localhost:4317). None lets the
exporter fall back to the standard OTEL_EXPORTER_OTLP_ENDPOINT env var
and its default. Passed to the exporter builder directly; nothing here
mutates the process environment.
otel_gcp_project: Option<String>Google Cloud project ID for GCP-native OTel export. If None, auto-detects from ADC or environment.
Implementations§
Source§impl TelemetryConfig
impl TelemetryConfig
Sourcepub fn init(&self) -> Result<TelemetryGuard, Box<dyn Error>>
pub fn init(&self) -> Result<TelemetryGuard, Box<dyn Error>>
Initialize telemetry subsystems based on configuration.
When otel-otlp is enabled and otel_traces/otel_metrics are set,
this configures OTLP exporters that send data to whatever endpoint is set
via the standard OTEL_EXPORTER_OTLP_ENDPOINT env var (defaults to
http://localhost:4317 for gRPC).
When otel-gcp is enabled, use init_gcp() to set up Google Cloud-native
exporters, or configure providers manually and call init_with_tracer().
The returned TelemetryGuard must be held alive for the duration of the
application. Dropping it triggers a flush and shutdown of all exporters.
Sourcepub async fn init_gcp(
&self,
) -> Result<TelemetryGuard, Box<dyn Error + Send + Sync>>
pub async fn init_gcp( &self, ) -> Result<TelemetryGuard, Box<dyn Error + Send + Sync>>
Initialize telemetry with Google Cloud-native exporters (Cloud Trace + Cloud Monitoring).
This is the GCP counterpart to init(). It uses opentelemetry-gcloud-trace for
span export and opentelemetry_gcloud_monitoring_exporter for metrics.
If otel_gcp_project is set, it is used as the GCP project ID. Otherwise the
project ID is auto-detected from ADC or the environment.
The returned TelemetryGuard must be held alive for the duration of the
application. Dropping it triggers a flush and shutdown of all exporters.
Trait Implementations§
Source§impl Clone for TelemetryConfig
impl Clone for TelemetryConfig
Source§fn clone(&self) -> TelemetryConfig
fn clone(&self) -> TelemetryConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].