Skip to content

Improve instrumentation and gen_ai spec adherence#222

Merged
anbuzin merged 5 commits into
mainfrom
improve-gen-ai-spec
Jul 22, 2026
Merged

Improve instrumentation and gen_ai spec adherence#222
anbuzin merged 5 commits into
mainfrom
improve-gen-ai-spec

Conversation

@anbuzin

@anbuzin anbuzin commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator
  • adds gen_ai semconv conversion to otel adapter for maximum downstream compatibility
  • plumbs previously dropped values into spans: finish reason, response id/model, usage details

@anbuzin
anbuzin requested a review from msullivan July 17, 2026 23:26
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ai-python Ready Ready Preview, Comment Jul 22, 2026 7:34pm

@anbuzin anbuzin added the feature New functionality label Jul 17, 2026
@anbuzin
anbuzin requested a review from elprans July 20, 2026 18:27
@anbuzin
anbuzin force-pushed the improve-gen-ai-spec branch from a1930e3 to 830404e Compare July 21, 2026 21:20
@anbuzin
anbuzin force-pushed the durable-telemetry-2 branch from 023dbd1 to 69075d8 Compare July 22, 2026 17:21
Base automatically changed from durable-telemetry-2 to main July 22, 2026 17:25
Comment thread src/ai/experimental_telemetry/otel.py
return attrs


def _hack_get_field(obj: Any, name: str) -> Any:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just call it _get_field, probably?
what's the cause here though? sometimes we have objects and sometimes dicts?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's because of the span.py:111 import hack:

if TYPE_CHECKING:
    ...

    # 1. RunSpanData and friends are pydantic models. RunSpanData.params is
    #    typed as InferenceRequestParams.
    # 2. InferenceRequestParams.sampling (and other fields) have
    #    a ModelProviderDefault annotation.
    # 3. ModelProviderDefault is a plain setinel class that causes pydantic to
    #    freak out when building a schema.

    # also, importing without a guard would cause a circular import
    # in models/core/api.py
    _InferenceParams = params_.InferenceRequestParams
    _GenerateParams = params_.GenerateParams
else:
    _InferenceParams = Any
    _GenerateParams = Any

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there're ways i could try and fix it in a followup pr. if i succeed, we'll be able to delete this

@anbuzin
anbuzin merged commit 905e5c7 into main Jul 22, 2026
8 checks passed
@anbuzin
anbuzin deleted the improve-gen-ai-spec branch July 22, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants