Merge lp:~ralsina/tanuki-agent/log-req-id into lp:tanuki-agent

Proposed by Roberto Alsina on 2016-01-08
Status: Merged
Approved by: Roberto Alsina on 2016-01-08
Approved revision: 204
Merged at revision: 204
Proposed branch: lp:~ralsina/tanuki-agent/log-req-id
Merge into: lp:tanuki-agent
Diff against target: 66 lines (+13/-5)
2 files modified
agent.py (+11/-5)
test_agent.py (+2/-0)
To merge this branch: bzr merge lp:~ralsina/tanuki-agent/log-req-id
Reviewer Review Type Date Requested Status
Celso Providelo (community) 2016-01-08 Approve on 2016-01-08
Review via email: mp+282046@code.launchpad.net

Commit message

Log request-id on errors where it makes sense.

Description of the change

Log request-id on errors where it makes sense.

To post a comment you must log in.
Celso Providelo (cprov) wrote :

Thanks, Roberto.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'agent.py'
--- agent.py 2015-12-11 16:18:35 +0000
+++ agent.py 2016-01-08 18:37:54 +0000
@@ -218,7 +218,8 @@
218 formatted_extra = ';'.join('{}: {}'.format(k, ','.join(v))218 formatted_extra = ';'.join('{}: {}'.format(k, ','.join(v))
219 for k, v in res.json().get('extra', {}).items())219 for k, v in res.json().get('extra', {}).items())
220 self.log.error(220 self.log.error(
221 'Error %d getting SSO token %s: %s, %s',221 '[%s] Error %d getting SSO token %s: %s, %s',
222 res.headers.get('x-request-id'),
222 res.status_code,223 res.status_code,
223 sso_url,224 sso_url,
224 msg, formatted_extra)225 msg, formatted_extra)
@@ -266,7 +267,8 @@
266 timeout=self.nw_timeout)267 timeout=self.nw_timeout)
267 if r.status_code > 299:268 if r.status_code > 299:
268 self.log.error(269 self.log.error(
269 'Error %d registering at %s: %s',270 '[%s] Error %d registering at %s: %s',
271 r.headers.get('x-request-id'),
270 r.status_code,272 r.status_code,
271 self.register_url,273 self.register_url,
272 r.text)274 r.text)
@@ -278,7 +280,9 @@
278 self.queue_url = urllib.parse.urljoin(self.server, href)280 self.queue_url = urllib.parse.urljoin(self.server, href)
279 return True281 return True
280 except KeyError:282 except KeyError:
281 self.log.error("Malformed registration response: %s", r.json())283 self.log.error("[%s] Malformed registration response: %s",
284 r.headers.get('x-request-id'),
285 r.json())
282 return False286 return False
283 except requests.exceptions.ConnectionError as err:287 except requests.exceptions.ConnectionError as err:
284 self.log.error('Exception: %s', err)288 self.log.error('Exception: %s', err)
@@ -300,7 +304,8 @@
300 return False304 return False
301 elif r.status_code > 299:305 elif r.status_code > 299:
302 self.log.error(306 self.log.error(
303 'Error %d polling at %s: %s',307 '[%s] Error %d polling at %s: %s',
308 r.headers.get('x-request-id'),
304 r.status_code,309 r.status_code,
305 self.queue_url,310 self.queue_url,
306 r.text)311 r.text)
@@ -379,7 +384,8 @@
379 timeout=self.nw_timeout)384 timeout=self.nw_timeout)
380 if r.status_code > 299:385 if r.status_code > 299:
381 self.log.error(386 self.log.error(
382 'Error %d posting result at %s: %s',387 '[%s] Error %d posting result at %s: %s',
388 r.headers.get('x-request-id'),
383 r.status_code,389 r.status_code,
384 self.testresult_url,390 self.testresult_url,
385 r.text)391 r.text)
386392
=== modified file 'test_agent.py'
--- test_agent.py 2015-12-04 22:54:58 +0000
+++ test_agent.py 2016-01-08 18:37:54 +0000
@@ -49,6 +49,8 @@
49 def text(self):49 def text(self):
50 return self._text50 return self._text
5151
52 headers = {'x-request-id': 'foobar'}
53
5254
53epoch = datetime.datetime(1970, 1, 1)55epoch = datetime.datetime(1970, 1, 1)
5456

Subscribers

People subscribed via source and target branches

to all changes: