Skip to content

OpenTelemetry

Namespace: Vercel.AI.OpenTelemetry

public sealed class OpenTelemetry : ITelemetry

Telemetry integration that records GenAI spans on an ActivitySource. Maps to OpenTelemetry in packages/otel/src/open-telemetry.ts. Pass it in Integrations or register it with ITelemetry%5b%5d).

Inheritance: object

Implements: ITelemetry

Only the callbacks ITelemetry has are ported: text generation (root, step, model call, and tool spans), decide, and extract. The embed, rerank, speech, transcription, object, durable, and inference duration parts of upstream need events the port does not emit yet.

View source

public OpenTelemetry(OpenTelemetryOptions? options = null)

Creates the integration.

Parameters

Name Type Description
options OpenTelemetryOptions Options. Null uses the defaults.

View source

public IExecuteLanguageModelCall? ExecuteLanguageModelCall { get; }

Runs the provider call of a model call in an integration-specific context, so auto-instrumented provider requests can be associated with the model work. Maps to executeLanguageModelCall.

Value: IExecuteLanguageModelCall

View source

public IExecuteTool? ExecuteTool { get; }

Runs the execute function of a tool in an integration-specific context, so nested calls become children of the tool span. Maps to executeTool.

Value: IExecuteTool

View source

public Func<StreamAbortContext, CancellationToken, Task>? OnAbort { get; }

Called when a streamed generation is aborted before it completes. Maps to onAbort.

Value: Func<StreamAbortContext, CancellationToken, Task>

View source

public Func<DecideEvent, CancellationToken, Task>? OnDecideEnd { get; }

Called when an experimental decision completes. Maps to experimental_onDecideEnd.

Value: Func<DecideEvent, CancellationToken, Task>

View source

public Func<DecideEvent, CancellationToken, Task>? OnDecideStart { get; }

Called when an experimental decision begins. Maps to experimental_onDecideStart.

Value: Func<DecideEvent, CancellationToken, Task>

View source

public Func<DecisionModelEvent, CancellationToken, Task>? OnDecisionModelCallEnd { get; }

Called after the decision model response has been validated. Maps to experimental_onDecisionModelCallEnd.

Value: Func<DecisionModelEvent, CancellationToken, Task>

View source

public Func<DecisionModelEvent, CancellationToken, Task>? OnDecisionModelCallStart { get; }

Called before the decision model call begins. Maps to experimental_onDecisionModelCallStart.

Value: Func<DecisionModelEvent, CancellationToken, Task>

View source

public Func<EmbeddingModelCallEndEvent, CancellationToken, Task>? OnEmbedEnd { get; }

Called after each doEmbed call of embed and embedMany. Maps to onEmbedEnd.

Value: Func<EmbeddingModelCallEndEvent, CancellationToken, Task>

View source

public Func<EmbeddingModelCallStartEvent, CancellationToken, Task>? OnEmbedStart { get; }

Called before each doEmbed call of embed and embedMany. Maps to onEmbedStart.

Value: Func<EmbeddingModelCallStartEvent, CancellationToken, Task>

View source

public Func<IOperationEndEvent, CancellationToken, Task>? OnEnd { get; }

Called when an operation completes. Maps to onEnd. Receives a GenerateTextResult, a GenerateObjectEndEvent%601, an EmbedEndEvent, a RerankEndEvent or a TranscriptionEndEvent.

Value: Func<IOperationEndEvent, CancellationToken, Task>

View source

public Func<TelemetryErrorEvent, CancellationToken, Task>? OnError { get; }

Called when an unrecoverable error occurs during the generation. Maps to onError.

Value: Func<TelemetryErrorEvent, CancellationToken, Task>

View source

[Obsolete("Use OnDecideEnd instead.")]
public Func<EvaluateEvent, CancellationToken, Task>? OnEvaluateEnd { get; }

Deprecated alias of OnDecideEnd. Maps to experimental_onEvaluateEnd.

Value: Func<EvaluateEvent, CancellationToken, Task>

View source

[Obsolete("Use OnDecideStart instead.")]
public Func<EvaluateEvent, CancellationToken, Task>? OnEvaluateStart { get; }

Deprecated alias of OnDecideStart. Maps to experimental_onEvaluateStart.

Value: Func<EvaluateEvent, CancellationToken, Task>

View source

[Obsolete("Use OnDecisionModelCallEnd instead.")]
public Func<EvaluateModelEvent, CancellationToken, Task>? OnEvaluationModelCallEnd { get; }

Deprecated alias of OnDecisionModelCallEnd. Maps to experimental_onEvaluationModelCallEnd.

Value: Func<EvaluateModelEvent, CancellationToken, Task>

View source

[Obsolete("Use OnDecisionModelCallStart instead.")]
public Func<EvaluateModelEvent, CancellationToken, Task>? OnEvaluationModelCallStart { get; }

Deprecated alias of OnDecisionModelCallStart. Maps to experimental_onEvaluationModelCallStart.

Value: Func<EvaluateModelEvent, CancellationToken, Task>

View source

public Func<ExtractEndEvent, CancellationToken, Task>? OnExtractEnd { get; }

Called when an experimental extraction completes. Maps to experimental_onExtractEnd.

Value: Func<ExtractEndEvent, CancellationToken, Task>

View source

public Func<ExtractStartEvent, CancellationToken, Task>? OnExtractStart { get; }

Called when an experimental extraction begins. Maps to experimental_onExtractStart.

Value: Func<ExtractStartEvent, CancellationToken, Task>

View source

public Func<ExtractionModelCallEndEvent, CancellationToken, Task>? OnExtractionModelCallEnd { get; }

Called after the extraction model response has been validated. Maps to experimental_onExtractionModelCallEnd.

Value: Func<ExtractionModelCallEndEvent, CancellationToken, Task>

View source

public Func<ExtractionModelCallStartEvent, CancellationToken, Task>? OnExtractionModelCallStart { get; }

Called before the extraction model call begins. Maps to experimental_onExtractionModelCallStart.

Value: Func<ExtractionModelCallStartEvent, CancellationToken, Task>

View source

public Func<LanguageModelCallEndEvent, CancellationToken, Task>? OnLanguageModelCallEnd { get; }

Called after each provider model call returns, before tools run. Maps to onLanguageModelCallEnd.

Value: Func<LanguageModelCallEndEvent, CancellationToken, Task>

View source

public Func<LanguageModelCallStartEvent, CancellationToken, Task>? OnLanguageModelCallStart { get; }

Called before each provider model call. Maps to onLanguageModelCallStart.

Value: Func<LanguageModelCallStartEvent, CancellationToken, Task>

View source

public Func<GenerateObjectStepEndEvent, CancellationToken, Task>? OnObjectStepEnd { get; }

Called after the model call of generateObject and streamObject. Maps to onObjectStepEnd.

Value: Func<GenerateObjectStepEndEvent, CancellationToken, Task>

View source

public Func<GenerateObjectStepStartEvent, CancellationToken, Task>? OnObjectStepStart { get; }

Called before the model call of generateObject and streamObject. Maps to onObjectStepStart.

Value: Func<GenerateObjectStepStartEvent, CancellationToken, Task>

View source

public Func<RerankingModelCallEndEvent, CancellationToken, Task>? OnRerankEnd { get; }

Called after the doRerank call of rerank. Maps to onRerankEnd.

Value: Func<RerankingModelCallEndEvent, CancellationToken, Task>

View source

public Func<RerankingModelCallStartEvent, CancellationToken, Task>? OnRerankStart { get; }

Called before the doRerank call of rerank. Maps to onRerankStart.

Value: Func<RerankingModelCallStartEvent, CancellationToken, Task>

View source

public Func<IOperationStartEvent, CancellationToken, Task>? OnStart { get; }

Called when an operation begins, before any model call. Maps to onStart. Receives a GenerateTextStartEvent or a GenerateObjectStartEvent.

Value: Func<IOperationStartEvent, CancellationToken, Task>

View source

public Func<StepResult, CancellationToken, Task>? OnStepEnd { get; }

Called when a step completes. Maps to onStepEnd.

Value: Func<StepResult, CancellationToken, Task>

View source

public Func<GenerateTextStepErrorEvent, CancellationToken, Task>? OnStepError { get; }

Called when a step ends with an error before it produces a step result. Maps to onStepError.

Value: Func<GenerateTextStepErrorEvent, CancellationToken, Task>

View source

public Func<StepResult, CancellationToken, Task>? OnStepFinish { get; }

Deprecated alias of OnStepEnd. An integration with both gets both calls. Maps to onStepFinish.

Value: Func<StepResult, CancellationToken, Task>

View source

public Func<GenerateTextStepStartEvent, CancellationToken, Task>? OnStepStart { get; }

Called when a step begins, before the provider is called. Maps to onStepStart.

Value: Func<GenerateTextStepStartEvent, CancellationToken, Task>

View source

public Func<StreamTranscriptionEndEvent, CancellationToken, Task>? OnStreamTranscriptionEnd { get; }

Called when a stream transcription completes. Maps to experimental_onStreamTranscriptionEnd.

Value: Func<StreamTranscriptionEndEvent, CancellationToken, Task>

View source

public Func<StreamTranscriptionStartEvent, CancellationToken, Task>? OnStreamTranscriptionStart { get; }

Called when a stream transcription begins. Maps to experimental_onStreamTranscriptionStart.

Value: Func<StreamTranscriptionStartEvent, CancellationToken, Task>

View source

public Func<ToolExecutionEndEvent, CancellationToken, Task>? OnToolExecutionEnd { get; }

Called when a tool execution completes, with a result or an error. Maps to onToolExecutionEnd.

Value: Func<ToolExecutionEndEvent, CancellationToken, Task>

View source

public Func<ToolExecutionStartEvent, CancellationToken, Task>? OnToolExecutionStart { get; }

Called when a tool execution begins, before the tool runs. Maps to onToolExecutionStart.

Value: Func<ToolExecutionStartEvent, CancellationToken, Task>

View source

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