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

fix(openai): track client attributes for v1 SDK of OpenAI #522

Merged
merged 4 commits into from
Feb 26, 2024

Conversation

tonybaloney
Copy link
Contributor

@tonybaloney tonybaloney commented Feb 26, 2024

Adds base URL to the openAI v1+ SDK and the API version for Azure OpenAI

Fixes #479

Before:

Trace 12391879d7721f635e8c81ece142a59a
└── [08:53:43.832568] openai.embeddings, span 8a0632a8f425452a
    ├── Kind : CLIENT
    ├── Attributes : 
    │   ├── llm.request.type : embedding
    │   ├── llm.vendor : OpenAI
    │   ├── llm.request.model : embedding
    │   ├── llm.headers : None
    │   ├── llm.prompts.0.content : Ground control to Major Tom
    │   ├── llm.response.model : ada
    │   ├── llm.usage.total_tokens : 5
    │   └── llm.usage.prompt_tokens : 5
    └── Resources : 
        ├── telemetry.sdk.language : python
        ├── telemetry.sdk.name : opentelemetry
        ├── telemetry.sdk.version : 1.23.0
        └── service.name : unknown_service

After

Trace 2a237cbb28690e6a7841486a82211b14
└── [08:58:27.483496] openai.embeddings, span 2e300bb34bda19b4
    ├── Kind : CLIENT
    ├── Attributes : 
    │   ├── llm.request.type : embedding
    │   ├── llm.vendor : OpenAI
    │   ├── llm.request.model : embedding
    │   ├── llm.headers : None
    │   ├── llm.prompts.0.content : Ground control to Major Tom
    │   ├── openai.api_base : https://<redacted>.openai.azure.com/openai/
    │   ├── openai.api_version : 2023-07-01-preview
    │   ├── llm.response.model : ada
    │   ├── llm.usage.total_tokens : 5
    │   └── llm.usage.prompt_tokens : 5
    └── Resources : 
        ├── telemetry.sdk.language : python
        ├── telemetry.sdk.name : opentelemetry
        ├── telemetry.sdk.version : 1.23.0
        └── service.name : unknown_service

@CLAassistant
Copy link

CLAassistant commented Feb 26, 2024

CLA assistant check
All committers have signed the CLA.

@nirga
Copy link
Member

nirga commented Feb 26, 2024

Thanks @tonybaloney! Can you add a test for that?

@tonybaloney
Copy link
Contributor Author

Thanks @tonybaloney! Can you add a test for that?

Sure. Where are the existing test cases?

@nirga
Copy link
Member

nirga commented Feb 26, 2024

Thanks @tonybaloney! Can you add a test for that?

Sure. Where are the existing test cases?

https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-openai/tests

@nirga nirga changed the title Track client attributes for v1 SDK of OpenAI fix(openai): track client attributes for v1 SDK of OpenAI Feb 26, 2024
@tonybaloney
Copy link
Contributor Author

Updated the test cases for the existing wrappers and added a full test for Azure OpenAI client with the recording from a live API. This PR is ready for review

Copy link
Member

@nirga nirga left a comment

Choose a reason for hiding this comment

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

Nice work @tonybaloney, thank you so much!

@nirga nirga merged commit bb9b983 into traceloop:main Feb 26, 2024
7 checks passed
@tonybaloney tonybaloney deleted the openai_v1_attributes branch February 26, 2024 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 Feature: Add more properties to Span Attributes for OpenAI instrumentation
3 participants