TelemetrySpan
Namespace: Vercel.AI.OpenTelemetry
public static class TelemetrySpanStarts an Activity span and records errors on it.
Inheritance: object
Methods
Section titled “Methods”RecordAsync<T>(string, Func<Activity?, Task<T>>, Task<IReadOnlyDictionary<string, object?>>?, bool, ActivitySource?)
Section titled “RecordAsync<T>(string, Func<Activity?, Task<T>>, Task<IReadOnlyDictionary<string, object?>>?, bool, ActivitySource?)”public static Task<T> RecordAsync<T>(string name, Func<Activity?, Task<T>> action, Task<IReadOnlyDictionary<string, object?>>? attributes = null, bool endWhenDone = true, ActivitySource? activitySource = null)Runs <code class=“paramref”>action</code> inside a span named <code class=“paramref”>name</code>. An exception is recorded, the span is stopped, and the exception is rethrown.
Type parameters
| Name | Description |
|---|---|
T |
Result of <code class=“paramref”>action</code>. |
Parameters
| Name | Type | Description |
|---|---|---|
name |
string | Span name. |
action |
Func<Activity, Task<T>> | Work to run. The current span is null when nothing is listening. |
attributes |
Task<IReadOnlyDictionary<string, object>> | Tags applied before the action runs. Null adds none. |
endWhenDone |
bool | When false, a successful span stays open. Failures still stop the span. |
activitySource |
ActivitySource | Source for the span. Null uses ActivitySource. |
Returns: Task<T>
RecordError(Activity, object)
Section titled “RecordError(Activity, object)”public static void RecordError(Activity activity, object error)Sets the span status to error. Exceptions also record an exception event and, for ApiException, the HTTP status code.
Parameters
| Name | Type | Description |
|---|---|---|
activity |
Activity | Span to update. |
error |
object | Exception or other error value. |
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product