Skip to content

OpenTelemetryAiTelemetry

Namespace: Vercel.AI.OpenTelemetry

public sealed class OpenTelemetryAiTelemetry : IAiTelemetry

IAiTelemetry that records spans on ActivitySource.

Inheritance: object

Implements: IAiTelemetry

View source

public static readonly ActivitySource ActivitySource

Source used by String).

Value: ActivitySource

View source

public const string SourceName = "Vercel.AI"

Activity source name. Add this source to a TracerProvider.

Value: string

View source

public IDisposable Begin(string operation, string modelId)

Starts a span. Dispose it when the call finishes.

Parameters

Name Type Description
operation string
modelId string

Returns: IDisposable

View source

public void OnFinish(IDisposable span, FinishReason finishReason)

Records the final finish reason on the span opened by String).

Parameters

Name Type Description
span IDisposable
finishReason FinishReason

View source

public void OnUsage(IDisposable span, AudioUsage? usage)

Records speech or transcription usage on the span opened by String).

Parameters

Name Type Description
span IDisposable
usage AudioUsage

View source

public void OnUsage(IDisposable span, LanguageModelUsage usage)

Records token usage on the span opened by String).

Parameters

Name Type Description
span IDisposable
usage LanguageModelUsage

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product