OpenTelemetryRealtimeClientBuilderExtensions.UseOpenTelemetry Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds OpenTelemetry support to the realtime client pipeline, following the OpenTelemetry Semantic Conventions for Generative AI systems.
public static Microsoft.Extensions.AI.RealtimeClientBuilder UseOpenTelemetry(this Microsoft.Extensions.AI.RealtimeClientBuilder builder, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory = default, string? sourceName = default, Action<Microsoft.Extensions.AI.OpenTelemetryRealtimeClient>? configure = default);
static member UseOpenTelemetry : Microsoft.Extensions.AI.RealtimeClientBuilder * Microsoft.Extensions.Logging.ILoggerFactory * string * Action<Microsoft.Extensions.AI.OpenTelemetryRealtimeClient> -> Microsoft.Extensions.AI.RealtimeClientBuilder
<Extension()>
Public Function UseOpenTelemetry (builder As RealtimeClientBuilder, Optional loggerFactory As ILoggerFactory = Nothing, Optional sourceName As String = Nothing, Optional configure As Action(Of OpenTelemetryRealtimeClient) = Nothing) As RealtimeClientBuilder
Parameters
- builder
- RealtimeClientBuilder
- loggerFactory
- ILoggerFactory
An optional ILoggerFactory to use to create a logger for logging events.
- sourceName
- String
An optional source name that will be used on the telemetry data.
- configure
- Action<OpenTelemetryRealtimeClient>
An optional callback that can be used to configure the OpenTelemetryRealtimeClient instance.
Returns
The builder.
Exceptions
builder is null.
Remarks
The draft specification this follows is available at https://opentelemetry.io/docs/specs/semconv/gen-ai/. The specification is still experimental and subject to change; as such, the telemetry output by this client is also subject to change.
The following standard OpenTelemetry GenAI conventions are supported:
gen_ai.operation.name- Operation name ("realtime")gen_ai.request.model- Model name from optionsgen_ai.provider.name- Provider name from metadatagen_ai.response.id- Response ID from ResponseDone messagesgen_ai.usage.input_tokens- Input token countgen_ai.usage.output_tokens- Output token countgen_ai.request.max_tokens- Max output tokens from optionsgen_ai.system_instructions- Instructions from options (sensitive data)gen_ai.conversation.id- Conversation ID from responsegen_ai.tool.definitions- Tool definitions (sensitive data)server.address/server.port- Server endpoint infoerror.type- Error type on failures
Additionally, the following realtime-specific custom attributes are supported:
gen_ai.realtime.voice- Voice setting from optionsgen_ai.realtime.output_modalities- Output modalities (text, audio)gen_ai.realtime.voice_speed- Voice speed settinggen_ai.realtime.session_kind- Session kind (Realtime/Transcription)
Metrics include:
gen_ai.client.operation.duration- Duration histogramgen_ai.client.token.usage- Token usage histogram