Skip to content

Migrate OpenAI and Anthropic instrumentations to new OpenTelemetry semantic conventions #1586

@alexmojaki

Description

@alexmojaki

instrument_openai, instrument_openai_agents, and instrument_anthropic currently use a messy mix of legacy custom data formats. None use the semantic conventions in https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/ . We want to fix all that.

Eventually we want to only produce new-style data and not keep any legacy code around. This will require at least one major version bump. Ideally only one, but that might be tricky. It could help to have a branch into which several PRs are made.

Ideally we would be using opentelemetry-python-contrib libraries to reduce the maintenance load and avoid reinventing the wheel, but they seem to move very slowly. Here's the state they're currently in:

I think simultaneously updating behaviour and switching to these libraries is too difficult, especially as it would require making major contributions to those libraries. I've been waiting for them to catch up (e.g. instrument the Responses API) but it's been too slow. But we should still aim to use them eventually. So we should check what those libraries produce and try to align with them to avoid future breaking changes. If the contrib libraries don't follow semconv, an issue should be opened there. If there's no semconv for some particular bit of data, we should follow whatever the library does.

TODO:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions