Skip to content

Conversation

@xrmx
Copy link
Member

@xrmx xrmx commented Oct 16, 2024

What does this pull request do?

Fix a race condition between openai initialization and httpx instrumentation kicking in by loading the openai module when required. This should make the http spans from the api calls of the openai client recorded.

…r patching

Fix a race condition between openai initialization and httpx
instrumentation kicking in by loading the openai module when required.
This should make the http spans from the api calls of the openai client
recorded.
@xrmx xrmx requested a review from trentm October 16, 2024 15:47
def _uninstrument(self, **kwargs):
# unwrap only supports uninstrementing real module references so we
# import here.
import openai
Copy link
Member

Choose a reason for hiding this comment

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

This is unusual (directly importing the thing in an _uninstrument), right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, since openai depends on httpx if we load the openai module earlier and we are loaded before the httpx instrumentation the http spans from the openai client won't be traced

@xrmx xrmx merged commit b9ecd72 into main Oct 17, 2024
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.

4 participants