pub struct ObservableChatClient<C: ChatClient> { /* private fields */ }Expand description
A ChatClient decorator that emits a chat span per request following the
OpenTelemetry GenAI semantic conventions.
Message-content capture (gen_ai.input.messages / gen_ai.output.messages,
plus gen_ai.system_instructions / gen_ai.tool.definitions) is off by
default; enable it with ObservableChatClient::with_content_capture,
mirroring Python’s enable_sensitive_data flag — or construct via
ObservableChatClient::from_env to read that flag from
ENABLE_SENSITIVE_DATA.
Implementations§
Source§impl<C: ChatClient> ObservableChatClient<C>
impl<C: ChatClient> ObservableChatClient<C>
Sourcepub fn new(inner: C, system: impl Into<String>) -> Self
pub fn new(inner: C, system: impl Into<String>) -> Self
Wrap inner, tagging spans with the given provider/system name (the
gen_ai.system / gen_ai.provider.name attributes), e.g. "openai"
or "anthropic".
Sourcepub fn from_env(inner: C, system: impl Into<String>) -> Self
pub fn from_env(inner: C, system: impl Into<String>) -> Self
Wrap inner using ObservabilityConfig::from_env to decide whether
content capture is enabled (ENABLE_SENSITIVE_DATA). Equivalent to:
ObservableChatClient::new(inner, system)
.with_content_capture(ObservabilityConfig::from_env().enable_sensitive_data)Sourcepub fn with_content_capture(self, capture: bool) -> Self
pub fn with_content_capture(self, capture: bool) -> Self
Enable or disable capturing message content on spans (default: off).
Sourcepub fn with_observability_config(self, config: ObservabilityConfig) -> Self
pub fn with_observability_config(self, config: ObservabilityConfig) -> Self
Replace the whole ObservabilityConfig — content capture and the
GenAI semantic-convention version this client emits for.