Skip to content

TelemetryAttributes

Namespace: Vercel.AI.OpenTelemetry

public static class TelemetryAttributes

Selects and sanitizes OpenTelemetry attribute values.

Inheritance: object

View source

Sanitize(IReadOnlyDictionary<string, object?>?)

Section titled “Sanitize(IReadOnlyDictionary<string, object?>?)”
public static IReadOnlyDictionary<string, object?> Sanitize(IReadOnlyDictionary<string, object?>? attributes)

Drops entries that SanitizeValue(object) rejects. A null map returns an empty map.

Parameters

Name Type Description
attributes IReadOnlyDictionary<string, object> Attributes to sanitize.

Returns: IReadOnlyDictionary<string, object>

View source

public static object? SanitizeValue(object? value)

Returns a scalar or a homogeneous primitive array. Non-finite numbers and mixed or empty arrays are dropped.

Parameters

Name Type Description
value object Candidate attribute value.

Returns: object

View source

SelectAttributes(TelemetrySelection?, IReadOnlyDictionary<string, object?>?)

Section titled “SelectAttributes(TelemetrySelection?, IReadOnlyDictionary<string, object?>?)”
public static IReadOnlyDictionary<string, object?> SelectAttributes(TelemetrySelection? telemetry, IReadOnlyDictionary<string, object?>? attributes)

Selects attributes, resolving input and output callbacks and dropping values that cannot be recorded.

Parameters

Name Type Description
telemetry TelemetrySelection Recording switches. Null records every supplied value.
attributes IReadOnlyDictionary<string, object> Literal values and ResolvableTelemetryAttribute callbacks.

Returns: IReadOnlyDictionary<string, object>

View source

SelectTelemetryAttributesAsync(TelemetrySelection?, IReadOnlyDictionary<string, object?>?, CancellationToken)

Section titled “SelectTelemetryAttributesAsync(TelemetrySelection?, IReadOnlyDictionary<string, object?>?, CancellationToken)”
public static Task<IReadOnlyDictionary<string, object?>> SelectTelemetryAttributesAsync(TelemetrySelection? telemetry, IReadOnlyDictionary<string, object?>? attributes, CancellationToken cancellationToken = default)

Selects attributes without sanitizing them. Disabled telemetry returns an empty map. Null resolver results are omitted.

Parameters

Name Type Description
telemetry TelemetrySelection Recording switches. Null records every supplied value.
attributes IReadOnlyDictionary<string, object> Literal values and ResolvableTelemetryAttribute callbacks.
cancellationToken CancellationToken Cancels resolver work.

Returns: Task<IReadOnlyDictionary<string, object>>

View source

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