OpenAiTelemetry unstable
The OpenAiTelemetry module defines OpenAI-specific telemetry attributes
and a helper for adding them to a tracing span. It keeps the standard GenAI
telemetry attributes and adds service tier and system fingerprint under
openai.*.
Models
The attributes used to describe telemetry in the context of Generative Artificial Intelligence (GenAI) Models requests and responses.
Details
These attributes follow the OpenTelemetry generative AI semantic conventions: https://opentelemetry.io/docs/specs/semconv/attributes-registry/gen-ai/
Signature
type OpenAiTelemetryAttributes = Simplify<Telemetry.GenAITelemetryAttributes & Telemetry.AttributesWithPrefix<RequestAttributes, "openai.request"> & Telemetry.AttributesWithPrefix<ResponseAttributes, "openai.response">>OpenAI request metadata, written under openai.request.*.
Signature
interface RequestAttributes { readonly serviceTier?: string & {} | WellKnownServiceTier | null;}Telemetry attributes which are part of the GenAI specification and are
namespaced by openai.response.
Signature
interface ResponseAttributes { readonly serviceTier?: string | null; readonly systemFingerprint?: string | null;}The openai.request.service_tier attribute has the following
list of well-known values.
Details
If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
Signature
type WellKnownServiceTier = "auto" | "default"Options
Options accepted by addGenAIAnnotations, combining standard GenAI
telemetry attributes with optional OpenAI request and response attributes.
Signature
type OpenAiTelemetryAttributeOptions = Telemetry.GenAITelemetryAttributeOptions & { openai?: { request?: RequestAttributes; response?: ResponseAttributes; };}Tracing
addGenAIAnnotations
unstableApplies the specified OpenAI GenAI telemetry attributes to the provided
Span.
When to use
Use to annotate an existing OpenTelemetry span with standard GenAI attributes plus OpenAI-specific request and response metadata.
Gotchas
Mutates the supplied Span in place.
See
- OpenAiTelemetryAttributeOptions for the accepted telemetry attributes
- Telemetry.addGenAIAnnotations for the provider-neutral annotation helper
Signature
declare const addGenAIAnnotations: { (options: OpenAiTelemetryAttributeOptions): (span: Span) => void; (span: Span, options: OpenAiTelemetryAttributeOptions): void;}