[geany/www.geany.org] 6a0317: Log request duration of Github API calls

Enrico Tröger git-noreply at xxxxx
Sat Jun 29 08:15:25 UTC 2019


Branch:      refs/heads/issue5_geany_themes_preview
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Sat, 29 Jun 2019 08:15:25 UTC
Commit:      6a0317bba2727d909c84f25f9da74d251168c224
             https://github.com/geany/www.geany.org/commit/6a0317bba2727d909c84f25f9da74d251168c224

Log Message:
-----------
Log request duration of Github API calls


Modified Paths:
--------------
    static_docs/github_client.py

Modified: static_docs/github_client.py
9 lines changed, 9 insertions(+), 0 deletions(-)
===================================================================
@@ -41,6 +41,7 @@ def get_file_contents(self, filename, user=None, repository=None):
         with requests.get(url, timeout=HTTP_REQUEST_TIMEOUT, stream=False) as response:
             response_json = response.json()
             self._log_rate_limit(response)
+            self._log_request(response)
 
         # parse response
         return self._parse_fetch_file_response(response_json)
@@ -51,6 +52,14 @@ def _log_rate_limit(self, response):
         rate_limit = response.headers['X-RateLimit-Limit']
         logger.info('Github rate limits: %s/%s', rate_limit_remaining, rate_limit)
 
+    # ----------------------------------------------------------------------
+    def _log_request(self, response):
+        logger.info(
+            'Requesting "{} {}" took {}s'.format(
+                response.request.method,
+                response.request.url,
+                response.elapsed.total_seconds()))
+
     # ----------------------------------------------------------------------
     def _parse_fetch_file_response(self, response_json):
         content = response_json['content']



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list