-
Notifications
You must be signed in to change notification settings - Fork 822
Closed
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is neededinstrumentation
Description
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.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is neededinstrumentation