Fix HTTP tracer tests (#127)

This commit is contained in:
Yuge Zhang
2025-10-07 22:30:36 -07:00
committed by GitHub
parent 685eea70a6
commit e11036cf7b
2 changed files with 10 additions and 3 deletions
+3
View File
@@ -37,6 +37,9 @@ class HttpTracer(BaseTracer):
and we do not recommend using it in production.
It is primarily for demonstration and testing purposes.
Deprecated: This tracer is deprecated and will be removed in a future version.
Please use LLMProxy as an alternative.
Attributes:
include_headers: Whether to include HTTP headers in the spans.
Headers may contain sensitive information. Use with caution.
+7 -3
View File
@@ -17,8 +17,10 @@ from agentlightning.tracer.http import HttpTracer
def sync_http_function():
"""A simple synchronous function that makes HTTP requests."""
response = requests.get("https://httpbingo.org/get")
response2 = requests.post("https://httpbingo.org/post", json={"test": "data"})
s = requests.Session()
s.headers.update({"Accept-Encoding": "gzip, deflate"}) # no zstd
response = s.get("https://httpbingo.org/get")
response2 = s.post("https://httpbingo.org/post", json={"test": "data"})
return {
"get_status": response.status_code,
"post_status": response2.status_code,
@@ -29,7 +31,9 @@ def sync_http_function():
async def async_http_function():
"""A simple asynchronous function that makes HTTP requests."""
async with aiohttp.ClientSession() as session:
async with aiohttp.ClientSession(
auto_decompress=True, headers={"Accept-Encoding": "gzip, deflate"} # exclude zstd/brotli
) as session:
async with session.get("https://httpbingo.org/get") as response:
get_data = await response.json()
get_status = response.status