You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe your environment
Python 3.10.3
opentelemetry-api==1.12.0rc2
opentelemetry-sdk==1.12.0rc2
opentelemetry-instrumentation-httpx==0.32b0
Steps to reproduce
Run this example:
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
import httpx, asyncio
def httpx_request_hook(span, request):
print("test")
HTTPXClientInstrumentor().instrument(request_hook=httpx_request_hook)
# This succeeds
with httpx.Client() as client:
client.get("http://example.com")
async def test_func():
async with httpx.AsyncClient() as client:
await client.get("http://example.com")
# this fails with `TypeError: object NoneType can't be used in 'await' expression`
asyncio.run(test_func())
What is the expected behavior?
After instrumentation it should be possible to successfully use httpx in both sync and async contexts.
What is the actual behavior?
If a non-async hook is provided then an exception is raised when the AsyncClient is used. If an async hook is provided then it never executes when the non-async Client is used.
Additional context
It seems to me this should either allow both async and sync hooks to be provided separately. Or it should require that the hook be non-blocking and only support non-async hooks.
The text was updated successfully, but these errors were encountered:
I'm willing to write up a PR with either of the suggestions in "Additional context" or some other option if someone closer to the project wants to weigh in on what the preferred approach would be.
Describe your environment
Python 3.10.3
opentelemetry-api==1.12.0rc2
opentelemetry-sdk==1.12.0rc2
opentelemetry-instrumentation-httpx==0.32b0
Steps to reproduce
Run this example:
What is the expected behavior?
After instrumentation it should be possible to successfully use httpx in both sync and async contexts.
What is the actual behavior?
If a non-async hook is provided then an exception is raised when the AsyncClient is used. If an async hook is provided then it never executes when the non-async Client is used.
Additional context
It seems to me this should either allow both async and sync hooks to be provided separately. Or it should require that the hook be non-blocking and only support non-async hooks.
The text was updated successfully, but these errors were encountered: