GenAI span attributes with OpenAI's own (Effect's OpenAiTelemetry):
the shared gen_ai.* groups and openai.request.* /
openai.response.*.
Classes#
Functions#
add_gen_ai_annotations#
add_gen_ai_annotations(span, options) -> NoneWrite the shared groups, then OpenAI's.
| Parameter | Type | Description |
|---|---|---|
span | Span | |
options | OpenAiTelemetryAttributeOptions |
def add_gen_ai_annotations(span: Span, options: OpenAiTelemetryAttributeOptions) -> None:
"""Write the shared groups, then OpenAI's."""
T.add_gen_ai_annotations(span, options)
openai = options.get("openai")
if openai is None:
return
request = openai.get("request")
if request is not None:
T.add_span_attributes(span, "openai.request", request)
response = openai.get("response")
if response is not None:
T.add_span_attributes(span, "openai.response", response)