mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-19 15:36:02 +00:00
Add http_trace option in Client to trace the library's HTTP requests
This commit is contained in:
parent
4a76464ac9
commit
77ec49782a
@ -189,6 +189,12 @@ class Client:
|
||||
this is ``False`` then those events will not be dispatched (due to performance considerations).
|
||||
To enable these events, this must be set to ``True``. Defaults to ``False``.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
http_trace: :class:`aiohttp.TraceConfig`
|
||||
The trace configuration to use for tracking HTTP requests the library does using ``aiohttp``.
|
||||
This allows you to check requests the library is using. For more information, check the
|
||||
`aiottp documentation <https://docs.aiohttp.org/en/stable/client_advanced.html#client-tracing>`_.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
Attributes
|
||||
@ -208,7 +214,14 @@ class Client:
|
||||
proxy: Optional[str] = options.pop('proxy', None)
|
||||
proxy_auth: Optional[aiohttp.BasicAuth] = options.pop('proxy_auth', None)
|
||||
unsync_clock: bool = options.pop('assume_unsync_clock', True)
|
||||
self.http: HTTPClient = HTTPClient(self.loop, proxy=proxy, proxy_auth=proxy_auth, unsync_clock=unsync_clock)
|
||||
http_trace: Optional[aiohttp.TraceConfig] = options.pop('http_trace', None)
|
||||
self.http: HTTPClient = HTTPClient(
|
||||
self.loop,
|
||||
proxy=proxy,
|
||||
proxy_auth=proxy_auth,
|
||||
unsync_clock=unsync_clock,
|
||||
http_trace=http_trace,
|
||||
)
|
||||
|
||||
self._handlers: Dict[str, Callable[..., None]] = {
|
||||
'ready': self._handle_ready,
|
||||
|
@ -331,6 +331,7 @@ class HTTPClient:
|
||||
proxy: Optional[str] = None,
|
||||
proxy_auth: Optional[aiohttp.BasicAuth] = None,
|
||||
unsync_clock: bool = True,
|
||||
http_trace: Optional[aiohttp.TraceConfig] = None,
|
||||
) -> None:
|
||||
self.loop: asyncio.AbstractEventLoop = loop
|
||||
self.connector: aiohttp.BaseConnector = connector or MISSING
|
||||
@ -341,6 +342,7 @@ class HTTPClient:
|
||||
self.bot_token: bool = False
|
||||
self.proxy: Optional[str] = proxy
|
||||
self.proxy_auth: Optional[aiohttp.BasicAuth] = proxy_auth
|
||||
self.http_trace: Optional[aiohttp.TraceConfig] = http_trace
|
||||
self.use_clock: bool = not unsync_clock
|
||||
|
||||
user_agent = 'DiscordBot (https://github.com/Rapptz/discord.py {0}) Python/{1[0]}.{1[1]} aiohttp/{2}'
|
||||
@ -540,7 +542,10 @@ class HTTPClient:
|
||||
self.connector = aiohttp.TCPConnector(loop=self.loop, limit=0)
|
||||
|
||||
self.__session = aiohttp.ClientSession(
|
||||
connector=self.connector, ws_response_class=DiscordClientWebSocketResponse, loop=self.loop
|
||||
connector=self.connector,
|
||||
ws_response_class=DiscordClientWebSocketResponse,
|
||||
loop=self.loop,
|
||||
trace_configs=None if self.http_trace is None else [self.http_trace],
|
||||
)
|
||||
self._global_over = asyncio.Event()
|
||||
self._global_over.set()
|
||||
|
Loading…
x
Reference in New Issue
Block a user