-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
httpx: support
capture_headers
(#719)
- Loading branch information
Showing
10 changed files
with
227 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import httpx | ||
from opentelemetry.trace import Span | ||
from typing import Any, Awaitable, Callable, NamedTuple | ||
|
||
class RequestInfo(NamedTuple): | ||
"""Information about an HTTP request. | ||
This is the second parameter passed to the `RequestHook` function. | ||
""" | ||
method: bytes | ||
url: httpx.URL | ||
headers: httpx.Headers | ||
stream: httpx.SyncByteStream | httpx.AsyncByteStream | None | ||
extensions: dict[str, Any] | None | ||
|
||
class ResponseInfo(NamedTuple): | ||
"""Information about an HTTP response. | ||
This is the second parameter passed to the `ResponseHook` function. | ||
""" | ||
status_code: int | ||
headers: httpx.Headers | ||
stream: httpx.SyncByteStream | httpx.AsyncByteStream | None | ||
extensions: dict[str, Any] | None | ||
RequestHook = Callable[[Span, RequestInfo], None] | ||
ResponseHook = Callable[[Span, RequestInfo, ResponseInfo], None] | ||
AsyncRequestHook = Callable[[Span, RequestInfo], Awaitable[None]] | ||
AsyncResponseHook = Callable[[Span, RequestInfo, ResponseInfo], Awaitable[None]] |
Oops, something went wrong.