pub struct GenAiSpanBuilder { /* private fields */ }Available on crate feature
telemetry only.Expand description
Builder for creating model call spans with full OTel GenAI semconv attributes.
Providers use this to construct spans with all available metadata.
Fields not set are omitted from the span (recorded as Empty).
§Example
use adk_telemetry::semconv::{GenAiSpanBuilder, GenAiProvider, GenAiOperation};
let span = GenAiSpanBuilder::new(GenAiProvider::Gemini, GenAiOperation::Chat, "gemini-2.5-flash")
.stream(true)
.temperature(0.7)
.max_tokens(4096)
.build();Implementations§
Source§impl GenAiSpanBuilder
impl GenAiSpanBuilder
Sourcepub fn new(
provider: GenAiProvider,
operation: GenAiOperation,
model: impl Into<String>,
) -> GenAiSpanBuilder
Available on crate feature genai-semconv only.
pub fn new( provider: GenAiProvider, operation: GenAiOperation, model: impl Into<String>, ) -> GenAiSpanBuilder
genai-semconv only.Create a new span builder with required fields.
Sourcepub fn stream(self, stream: bool) -> GenAiSpanBuilder
Available on crate feature genai-semconv only.
pub fn stream(self, stream: bool) -> GenAiSpanBuilder
genai-semconv only.Set whether this is a streaming request.
Sourcepub fn temperature(self, temp: f64) -> GenAiSpanBuilder
Available on crate feature genai-semconv only.
pub fn temperature(self, temp: f64) -> GenAiSpanBuilder
genai-semconv only.Set the temperature parameter.
Sourcepub fn max_tokens(self, max: i64) -> GenAiSpanBuilder
Available on crate feature genai-semconv only.
pub fn max_tokens(self, max: i64) -> GenAiSpanBuilder
genai-semconv only.Set the max tokens parameter.
Sourcepub fn top_p(self, p: f64) -> GenAiSpanBuilder
Available on crate feature genai-semconv only.
pub fn top_p(self, p: f64) -> GenAiSpanBuilder
genai-semconv only.Set the top_p parameter.
Sourcepub fn top_k(self, k: f64) -> GenAiSpanBuilder
Available on crate feature genai-semconv only.
pub fn top_k(self, k: f64) -> GenAiSpanBuilder
genai-semconv only.Set the top_k parameter.
Sourcepub fn conversation_id(self, id: impl Into<String>) -> GenAiSpanBuilder
Available on crate feature genai-semconv only.
pub fn conversation_id(self, id: impl Into<String>) -> GenAiSpanBuilder
genai-semconv only.Set the conversation/session ID for correlation.
Sourcepub fn build(self) -> Span
Available on crate feature genai-semconv only.
pub fn build(self) -> Span
genai-semconv only.Build and return the tracing Span.
The span name follows the pattern: gen_ai.{operation_name} {model}.
All gen_ai.* response and usage fields are pre-declared as Empty
so they can be recorded later via GenAiResponseRecorder.
Auto Trait Implementations§
impl Freeze for GenAiSpanBuilder
impl RefUnwindSafe for GenAiSpanBuilder
impl Send for GenAiSpanBuilder
impl Sync for GenAiSpanBuilder
impl Unpin for GenAiSpanBuilder
impl UnsafeUnpin for GenAiSpanBuilder
impl UnwindSafe for GenAiSpanBuilder
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