async def _wrapped_async_send( wrapped, # type: BoundFunctionWrapper instance, # type: httpx.AsyncClient args, # type: typing.Tuple[httpx.Request], kwargs, # type: typing.Dict[typing.Str, typing.Any] ): # type: (...) -> typing.Coroutine[None, None, httpx.Response] req = get_argument_value(args, kwargs, 0, "request") pin = Pin.get_from(instance) if not pin or not pin.enabled(): return await wrapped(*args, **kwargs) with pin.tracer.trace("http.request", service=ext_service(pin, config.httpx), span_type=SpanTypes.HTTP) as span: _init_span(span, req) resp = None try: resp = await wrapped(*args, **kwargs) return resp finally: _set_span_meta(span, req, resp)
def test_infer_arg_value_miss(args, kwargs, pos, kw): with pytest.raises(ArgumentError) as e: get_argument_value(args, kwargs, pos, kw) assert e.value == "%s (at position %d)" % (kw, pos)
def test_infer_arg_value_hit(args, kwargs, pos, kw, expected): assert get_argument_value(args, kwargs, pos, kw) == expected