Skip to content

feat: aiohttp instrumentation#34

Merged
jy-tan merged 3 commits intomainfrom
aiohttp-instrumentation
Jan 15, 2026
Merged

feat: aiohttp instrumentation#34
jy-tan merged 3 commits intomainfrom
aiohttp-instrumentation

Conversation

@jy-tan
Copy link
Contributor

@jy-tan jy-tan commented Jan 15, 2026

Summary

  • Add complete aiohttp HTTP client instrumentation with RECORD/REPLAY support
  • Improve socket instrumentation to suppress false positive warnings from instrumented HTTP clients
  • Add comprehensive e2e test suite for aiohttp

Changes

aiohttp Instrumentation

  • Instrument ClientSession._request() to capture/replay all HTTP client calls
  • Support for all HTTP methods, headers, query params, request/response bodies
  • Mock response class (_MockClientResponse) for REPLAY mode
  • E2e test suite with 21 test cases covering various HTTP scenarios

Socket Instrumentation Improvement

  • Changed detection logic from checking calling_library != "ProtobufCommunicator" to calling_library is None
  • HTTP client instrumentations (httpx, aiohttp, requests, urllib3) now set calling_library_context during requests
  • This suppresses false positive "unpatched dependency" warnings for internal socket calls

Documentation

  • Added notes.md for aiohttp documenting the aiohappyeyeballs limitation where some socket warnings persist due to asyncio callback context propagation

Unit Tests

  • Added test_metrics.py and test_resilience.py

Test Results

Instrumentation Tests Socket Warnings
aiohttp 21 passed Expected (aiohappyeyeballs)
httpx 30 passed 0
requests 17 passed 0
urllib3 19 passed 0

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 13 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="drift/instrumentation/aiohttp/instrumentation.py">

<violation number="1" location="drift/instrumentation/aiohttp/instrumentation.py:814">
P2: HTTP header lookup should be case-insensitive. The `content_type` property uses `self._headers.get("content-type", ...)` which won't match headers stored with different casing like "Content-Type". This will cause incorrect content type detection during REPLAY mode.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@jy-tan jy-tan merged commit 252b3c7 into main Jan 15, 2026
16 checks passed
@jy-tan jy-tan deleted the aiohttp-instrumentation branch January 15, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants