Jaa


OpenTelemetryChatClientBuilderExtensions.UseOpenTelemetry Method

Definition

Adds OpenTelemetry support to the chat client pipeline, following the OpenTelemetry Semantic Conventions for Generative AI systems.

public static Microsoft.Extensions.AI.ChatClientBuilder UseOpenTelemetry (this Microsoft.Extensions.AI.ChatClientBuilder builder, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory = default, string? sourceName = default, Action<Microsoft.Extensions.AI.OpenTelemetryChatClient>? configure = default);
static member UseOpenTelemetry : Microsoft.Extensions.AI.ChatClientBuilder * Microsoft.Extensions.Logging.ILoggerFactory * string * Action<Microsoft.Extensions.AI.OpenTelemetryChatClient> -> Microsoft.Extensions.AI.ChatClientBuilder
<Extension()>
Public Function UseOpenTelemetry (builder As ChatClientBuilder, Optional loggerFactory As ILoggerFactory = Nothing, Optional sourceName As String = Nothing, Optional configure As Action(Of OpenTelemetryChatClient) = Nothing) As ChatClientBuilder

Parameters

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<OpenTelemetryChatClient>

An optional callback that can be used to configure the OpenTelemetryChatClient instance.

Returns

The builder.

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.

Applies to