pub struct TelemetrySetup {
pub service_name: String,
pub otlp_endpoint: Option<String>,
pub cloud_trace: bool,
pub capture_content: bool,
}Expand description
Configuration for telemetry export.
Use the builder methods to configure the desired exporters, then call init
to set up the global tracing subscriber.
§Examples
use gemini_adk_rs::telemetry::setup::TelemetrySetup;
// Basic setup with console logging only (requires `tracing-support` feature)
TelemetrySetup::new("my-agent-service").init().unwrap();
// With OTLP export (requires `otel-otlp` feature)
TelemetrySetup::new("my-agent-service")
.with_otlp("http://localhost:4317")
.with_content_capture(true)
.init()
.unwrap();
// With Google Cloud Trace (requires `otel-gcp` feature)
TelemetrySetup::new("my-agent-service")
.with_cloud_trace()
.init()
.unwrap();Fields§
§service_name: StringService name for OTel resource identification.
otlp_endpoint: Option<String>OTLP gRPC endpoint (e.g., http://localhost:4317).
When set, enables OTLP trace export (requires otel-otlp feature).
cloud_trace: boolEnable Google Cloud Trace export (requires otel-gcp feature).
capture_content: boolWhether to capture prompt/completion content in spans.
Defaults to false to avoid logging sensitive data.
Implementations§
Source§impl TelemetrySetup
impl TelemetrySetup
Sourcepub fn new(service_name: impl Into<String>) -> Self
pub fn new(service_name: impl Into<String>) -> Self
Create a new telemetry setup with the given service name.
Defaults to console logging only, no OTLP or Cloud Trace export, and content capture disabled.
Sourcepub fn with_otlp(self, endpoint: impl Into<String>) -> Self
pub fn with_otlp(self, endpoint: impl Into<String>) -> Self
Set the OTLP gRPC endpoint for trace export.
Requires the otel-otlp feature. If the feature is not enabled,
this value is ignored during init.
Sourcepub fn with_cloud_trace(self) -> Self
pub fn with_cloud_trace(self) -> Self
Enable Google Cloud Trace export.
Requires the otel-gcp feature. If the feature is not enabled,
this value is ignored during init.
Sourcepub fn with_content_capture(self, capture: bool) -> Self
pub fn with_content_capture(self, capture: bool) -> Self
Set whether to capture prompt/completion content in trace spans.
Defaults to false. When enabled, LLM request and response content
may be recorded in span attributes, which is useful for debugging
but should be disabled in production to avoid logging sensitive data.
Sourcepub fn init(self) -> Result<(), Box<dyn Error>>
pub fn init(self) -> Result<(), Box<dyn Error>>
Initialize the tracing subscriber with the configured exporters.
This is a convenience function that sets up:
tracing-subscriberwithEnvFilter(readsRUST_LOGenv var, defaults toinfo)- OpenTelemetry tracer (if
otlp_endpointis set andotel-otlpfeature is enabled) - Google Cloud Trace (if
cloud_traceis set andotel-gcpfeature is enabled) - Pretty log format for development
§Feature behavior
| Features enabled | Behavior |
|---|---|
| (none) | No-op, returns Ok(()) |
tracing-support | Console logging with env-filter |
tracing-support + otel-otlp | Console + OTLP trace export |
tracing-support + otel-gcp | Console + Cloud Trace export |
§Errors
Returns an error if the tracing subscriber cannot be set (e.g., if one is already registered globally), or if OTel exporter initialization fails.
Trait Implementations§
Source§impl Clone for TelemetrySetup
impl Clone for TelemetrySetup
Source§fn clone(&self) -> TelemetrySetup
fn clone(&self) -> TelemetrySetup
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more