[geany/www.geany.org] 52941f: Log request duration of Github API calls

Enrico Tröger git-noreply at xxxxx
Sun Jun 30 12:08:45 UTC 2019


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Sun, 30 Jun 2019 12:08:45 UTC
Commit:      52941f97ac36ae834b4ecd65c93bdab7f034372c
             https://github.com/geany/www.geany.org/commit/52941f97ac36ae834b4ecd65c93bdab7f034372c

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