Skip to content
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

Merged
merged 53 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
c7b3c97
[WIP] Initial commit for OpenAI instrumentation
karthikscale3 Jul 31, 2024
52a5f07
Merge branch 'main' into openai-opentelemetry
karthikscale3 Jul 31, 2024
6383978
Merge branch 'main' of github.com:Scale3-Labs/opentelemetry-python-co…
alizenhom Aug 7, 2024
e1bca1a
Loosen openai version for instrumentation + linting
alizenhom Aug 12, 2024
94c10f4
fix wrong patch.py import
alizenhom Aug 12, 2024
bb97ec9
add missing dependecies tiktoken & pydantic
alizenhom Aug 12, 2024
e15d443
remove async support from `StreamWrapper` until further notice
alizenhom Aug 12, 2024
1efdfcd
addressing comments:
alizenhom Aug 13, 2024
892d388
Merge branch 'open-telemetry:main' into openai-opentelemetry
alizenhom Aug 13, 2024
e7398a2
Merge branch 'open-telemetry:main' into openai-opentelemetry
alizenhom Aug 14, 2024
e601f6d
Merge branch 'open-telemetry:main' into openai-opentelemetry
alizenhom Aug 15, 2024
df3fc62
Merge branch 'open-telemetry:main' into openai-opentelemetry
alizenhom Sep 5, 2024
d04edad
Refactoring Openai instrumentation
alizenhom Sep 5, 2024
b8dde6c
Merge branch 'openai-opentelemetry' of github.com:Scale3-Labs/opentel…
alizenhom Sep 5, 2024
ec3c320
remove `SpanAttributes` and refactor streamwrapper
alizenhom Sep 5, 2024
706c6f2
change instrumentation name & fix some nits
alizenhom Sep 6, 2024
71aaeb6
change openai package name
alizenhom Sep 6, 2024
8495a24
cleanup setting prompt events & finish reasons
alizenhom Sep 6, 2024
885b7fd
catch connection drops and reraise error in streaming
alizenhom Sep 6, 2024
6ac04cb
run `tox -e generate`
alizenhom Sep 6, 2024
42370a7
run linter
alizenhom Sep 6, 2024
c5ef8c3
run `tox -e generate`
alizenhom Sep 6, 2024
d52460e
add changelog
alizenhom Sep 6, 2024
452d41a
test requirments + tox ini
alizenhom Sep 9, 2024
48fb3fb
Merge branch 'main' of github.com:open-telemetry/opentelemetry-python…
alizenhom Sep 25, 2024
e9a76c4
remove LLMSpanAttributes validation layer
alizenhom Sep 25, 2024
3d5a2b3
add tests
alizenhom Sep 25, 2024
b583aa0
enhance build settings
alizenhom Sep 27, 2024
ae9bc2a
Merge branch 'main' of github.com:open-telemetry/opentelemetry-python…
alizenhom Sep 27, 2024
f2a5cfa
address test comments
alizenhom Sep 27, 2024
e701678
Merge branch 'open-telemetry:main' into openai-opentelemetry
alizenhom Oct 1, 2024
a457df2
Merge branch 'main' into openai-opentelemetry
karthikscale3 Oct 7, 2024
3bdfd8f
run `tox -e generate` & `tox -e generate-workflows`
alizenhom Oct 8, 2024
41cbfd0
Update instrumentation/opentelemetry-instrumentation-openai/src/opent…
karthikscale3 Oct 9, 2024
f3b7c0e
Merge branch 'main' into openai-opentelemetry
karthikscale3 Oct 9, 2024
8813754
Merge branch 'main' into openai-opentelemetry
karthikscale3 Oct 16, 2024
578653d
change folder name to v2
alizenhom Oct 17, 2024
578a942
adjust all naming to -v2
alizenhom Oct 17, 2024
51f2438
run `tox -e generate`
alizenhom Oct 17, 2024
8b58f27
adjust tests
alizenhom Oct 17, 2024
d467eb1
set attributes only when span is recording
alizenhom Oct 17, 2024
ad7f198
`model` fallback to `gpt-3.5-turbo`
alizenhom Oct 17, 2024
5e4c2b2
Merge branch 'open-telemetry:main' into openai-opentelemetry
alizenhom Oct 19, 2024
bbee109
adjust `-v2` for linting
alizenhom Oct 19, 2024
9ac90f9
make sure span is recording before setting attributes
alizenhom Oct 19, 2024
2549f25
pass span_attributes when creating span inside `start_span`
alizenhom Oct 19, 2024
1dacf8d
adjust unwrap + add pydantic to test reqs
alizenhom Oct 21, 2024
4048410
bump openai support to `1.26.0`
alizenhom Oct 21, 2024
8fc4336
run `tox -e generate` & `tox -e generate-workflows`
alizenhom Oct 21, 2024
9e273f6
add uninstrument in tests + remove any none values from span attributes
alizenhom Oct 22, 2024
8e667de
cleanup
alizenhom Oct 22, 2024
592c18e
adjust `unwrap`
alizenhom Oct 22, 2024
cd8b098
Merge branch 'open-telemetry:main' into openai-opentelemetry
alizenhom Oct 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/lint_0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ env:

jobs:

lint-instrumentation-openai-v2:
name: instrumentation-openai-v2
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e lint-instrumentation-openai-v2

lint-resource-detector-container:
name: resource-detector-container
runs-on: ubuntu-latest
Expand Down
216 changes: 108 additions & 108 deletions .github/workflows/test_0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,114 @@ env:

jobs:

py38-test-instrumentation-openai-v2_ubuntu-latest:
name: instrumentation-openai-v2 3.8 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: "3.8"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py38-test-instrumentation-openai-v2 -- -ra

py39-test-instrumentation-openai-v2_ubuntu-latest:
name: instrumentation-openai-v2 3.9 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py39-test-instrumentation-openai-v2 -- -ra

py310-test-instrumentation-openai-v2_ubuntu-latest:
name: instrumentation-openai-v2 3.10 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py310-test-instrumentation-openai-v2 -- -ra

py311-test-instrumentation-openai-v2_ubuntu-latest:
name: instrumentation-openai-v2 3.11 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py311-test-instrumentation-openai-v2 -- -ra

py312-test-instrumentation-openai-v2_ubuntu-latest:
name: instrumentation-openai-v2 3.12 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py312-test-instrumentation-openai-v2 -- -ra

pypy3-test-instrumentation-openai-v2_ubuntu-latest:
name: instrumentation-openai-v2 pypy-3.8 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python pypy-3.8
uses: actions/setup-python@v5
with:
python-version: "pypy-3.8"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e pypy3-test-instrumentation-openai-v2 -- -ra

py38-test-resource-detector-container_ubuntu-latest:
name: resource-detector-container 3.8 Ubuntu
runs-on: ubuntu-latest
Expand Down Expand Up @@ -4407,111 +4515,3 @@ jobs:

- name: Run tests
run: tox -e py311-test-instrumentation-pymemcache-2 -- -ra

py311-test-instrumentation-pymemcache-3_ubuntu-latest:
name: instrumentation-pymemcache-3 3.11 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py311-test-instrumentation-pymemcache-3 -- -ra

py311-test-instrumentation-pymemcache-4_ubuntu-latest:
name: instrumentation-pymemcache-4 3.11 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py311-test-instrumentation-pymemcache-4 -- -ra

py312-test-instrumentation-pymemcache-0_ubuntu-latest:
name: instrumentation-pymemcache-0 3.12 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py312-test-instrumentation-pymemcache-0 -- -ra

py312-test-instrumentation-pymemcache-1_ubuntu-latest:
name: instrumentation-pymemcache-1 3.12 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py312-test-instrumentation-pymemcache-1 -- -ra

py312-test-instrumentation-pymemcache-2_ubuntu-latest:
name: instrumentation-pymemcache-2 3.12 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py312-test-instrumentation-pymemcache-2 -- -ra

py312-test-instrumentation-pymemcache-3_ubuntu-latest:
name: instrumentation-pymemcache-3 3.12 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py312-test-instrumentation-pymemcache-3 -- -ra
108 changes: 108 additions & 0 deletions .github/workflows/test_1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,114 @@ env:

jobs:

py311-test-instrumentation-pymemcache-3_ubuntu-latest:
name: instrumentation-pymemcache-3 3.11 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py311-test-instrumentation-pymemcache-3 -- -ra

py311-test-instrumentation-pymemcache-4_ubuntu-latest:
name: instrumentation-pymemcache-4 3.11 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py311-test-instrumentation-pymemcache-4 -- -ra

py312-test-instrumentation-pymemcache-0_ubuntu-latest:
name: instrumentation-pymemcache-0 3.12 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py312-test-instrumentation-pymemcache-0 -- -ra

py312-test-instrumentation-pymemcache-1_ubuntu-latest:
name: instrumentation-pymemcache-1 3.12 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py312-test-instrumentation-pymemcache-1 -- -ra

py312-test-instrumentation-pymemcache-2_ubuntu-latest:
name: instrumentation-pymemcache-2 3.12 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py312-test-instrumentation-pymemcache-2 -- -ra

py312-test-instrumentation-pymemcache-3_ubuntu-latest:
name: instrumentation-pymemcache-3 3.12 Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e py312-test-instrumentation-pymemcache-3 -- -ra

py312-test-instrumentation-pymemcache-4_ubuntu-latest:
name: instrumentation-pymemcache-4 3.12 Ubuntu
runs-on: ubuntu-latest
Expand Down
Loading