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

logfire.instrument_httpx() breaks OpenAI SDK #529

Open
samuelcolvin opened this issue Oct 22, 2024 · 4 comments
Open

logfire.instrument_httpx() breaks OpenAI SDK #529

samuelcolvin opened this issue Oct 22, 2024 · 4 comments
Labels
Bug Bug related to the Logfire Python SDK

Comments

@samuelcolvin
Copy link
Member

Description

Once I've run

logfire.instrument_httpx()

if I then try to create an OpenAI client I get

  File "/Users/samuel/code/.../.venv/lib/python3.12/site-packages/openai/_client.py", line 337, in __init__
    super().__init__(
  File "/Users/samuel/code/.../.venv/lib/python3.12/site-packages/openai/_base_client.py", line 1420, in __init__
    raise TypeError(
TypeError: Invalid `http_client` argument; Expected an instance of `httpx.AsyncClient` but got <class 'httpx.AsyncClient'>

This is not our fault, but we could create a PR to OpenAI to try to fix it.

We should also allow

logfire.instrument_httpx(client)

So you can easily instrument one client but not all.

Python, Logfire & OS Versions, related packages (not required)

logfire="1.2.0"
platform="macOS-14.6.1-arm64-arm-64bit"
python="3.12.6 (main, Sep 20 2024, 17:42:55) [Clang 15.0.0 (clang-1500.0.40.1)]"
[related_packages]
requests="2.32.3"
pydantic="2.9.2"
openai="1.51.2"
protobuf="4.25.5"
rich="13.9.2"
executing="2.1.0"
opentelemetry-api="1.27.0"
opentelemetry-exporter-otlp-proto-common="1.27.0"
opentelemetry-exporter-otlp-proto-http="1.27.0"
opentelemetry-instrumentation="0.48b0"
opentelemetry-instrumentation-httpx="0.48b0"
opentelemetry-proto="1.27.0"
opentelemetry-sdk="1.27.0"
opentelemetry-semantic-conventions="0.48b0"
opentelemetry-util-http="0.48b0"
@samuelcolvin samuelcolvin added the Bug Bug related to the Logfire Python SDK label Oct 22, 2024
@Kludex
Copy link
Member

Kludex commented Oct 22, 2024

How our tests didn't get this? 🤔

Can we use VCR instead of mocking things?

@alexmojaki
Copy link
Contributor

@samuelcolvin samuelcolvin added the P3 Less than P2. label Oct 22, 2024
@alexmojaki
Copy link
Contributor

@alexmojaki
Copy link
Contributor

alexmojaki commented Oct 31, 2024

This is supposedly fixed now in OTEL contrib, we need to check when they next release, but nothing needs to be done on our side for now.

@alexmojaki alexmojaki removed the P3 Less than P2. label Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug related to the Logfire Python SDK
Projects
None yet
Development

No branches or pull requests

4 participants