-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Initial Support for Instrumenting OpenAI Python Library - Chat Completion Create #2759
Add Initial Support for Instrumenting OpenAI Python Library - Chat Completion Create #2759
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a first round of comments, thanks!
instrumentation/opentelemetry-instrumentation-openai/README.rst
Outdated
Show resolved
Hide resolved
instrumentation/opentelemetry-instrumentation-openai/pyproject.toml
Outdated
Show resolved
Hide resolved
instrumentation/opentelemetry-instrumentation-openai/pyproject.toml
Outdated
Show resolved
Hide resolved
...on/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/__init__.py
Outdated
Show resolved
Hide resolved
...telemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/span_attributes.py
Outdated
Show resolved
Hide resolved
...on/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/__init__.py
Outdated
Show resolved
Hide resolved
instrumentation/opentelemetry-instrumentation-openai/pyproject.toml
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
instrumentation/opentelemetry-instrumentation-openai/test-requirements.txt
Outdated
Show resolved
Hide resolved
...telemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/span_attributes.py
Outdated
Show resolved
Hide resolved
...ion/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/version.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
…ntrib into openai-opentelemetry
|
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great start, thanks a lot for doing this!
1. clean up prompt calculations to be deduced from last streaming chunk 2. save correct span name 3. remove recording exceptions and setting status to ok 4. remove saving stream chunks in events
instrumentation/opentelemetry-instrumentation-openai/pyproject.toml
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/patch.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/utils.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/utils.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/utils.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/utils.py
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/utils.py
Outdated
Show resolved
Hide resolved
…ween external and otel instrumentations (#4187) Some package managers (PyPi) don't provide means to reserve namespaces for projects. We also have a number of **external** instrumentation libraries in python that follow current guidance and use `opentelemetry-instrumentation-{component}` naming pattern. These libraries are hard to distinguish from otel-authored ones. Also, when someone (legitimately following existing guidance) creates an external instrumentation package like this, it blocks our ability to have OTel-authored instrumentation with this 'good' name. See open-telemetry/opentelemetry-python-contrib#2759 (comment) for real-life example. ## Changes This PR changes the recommendation to: - otel authored instrumentation should use `opentelemetry-instrumentation-*` pattern - external instrumentation should not use this pattern and should prefix lib name with their company/project/etc name * ~~[ ] Related issues #~~ * ~~[ ] Related [OTEP(s)](https://github.com/open-telemetry/oteps) #~~ * ~~[ ] Links to the prototypes (when adding or changing features)~~ * [x] [`CHANGELOG.md`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/CHANGELOG.md) file updated for non-trivial changes * ~~[ ] [`spec-compliance-matrix.md`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/spec-compliance-matrix.md) updated if necessary~~ --------- Co-authored-by: Armin Ruech <7052238+arminru@users.noreply.github.com>
…emetry-python-contrib into openai-opentelemetry
...on/opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/__init__.py
Outdated
Show resolved
Hide resolved
To my understanding it should be a fairly simple change. Is there a reason why we can't just pass in |
@lzchen addressed all of the above comments |
...ntelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/__init__.py
Outdated
Show resolved
Hide resolved
instrumentation/opentelemetry-instrumentation-openai-v2/test-requirements.txt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on this! LGTM
Thanks for the quick reviews @lzchen ! |
...ntelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/__init__.py
Outdated
Show resolved
Hide resolved
…ween external and otel instrumentations (open-telemetry#4187) Some package managers (PyPi) don't provide means to reserve namespaces for projects. We also have a number of **external** instrumentation libraries in python that follow current guidance and use `opentelemetry-instrumentation-{component}` naming pattern. These libraries are hard to distinguish from otel-authored ones. Also, when someone (legitimately following existing guidance) creates an external instrumentation package like this, it blocks our ability to have OTel-authored instrumentation with this 'good' name. See open-telemetry/opentelemetry-python-contrib#2759 (comment) for real-life example. ## Changes This PR changes the recommendation to: - otel authored instrumentation should use `opentelemetry-instrumentation-*` pattern - external instrumentation should not use this pattern and should prefix lib name with their company/project/etc name * ~~[ ] Related issues #~~ * ~~[ ] Related [OTEP(s)](https://github.com/open-telemetry/oteps) #~~ * ~~[ ] Links to the prototypes (when adding or changing features)~~ * [x] [`CHANGELOG.md`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/CHANGELOG.md) file updated for non-trivial changes * ~~[ ] [`spec-compliance-matrix.md`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/spec-compliance-matrix.md) updated if necessary~~ --------- Co-authored-by: Armin Ruech <7052238+arminru@users.noreply.github.com>
Thank for the contribution. When is this planned for release? |
it will be released separately (now and in the future), release is still in progress, got stuck on some minor issues. Hope to finish tomorrow. |
Thanks @lmolkova |
Description
This PR adds support for tracing the official python openai library.
This pull request introduces initial support for instrumenting the OpenAI Python library, specifically targeting the chat.completion.create method. This implementation aligns with the GenAI semantic conventions.
Fixes #1796
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
This is a work in progress PR at the moment and I plan to add unit tests and update this space.
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.