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
1=== modified file 'agent.py'
2--- agent.py 2015-12-11 16:18:35 +0000
3+++ agent.py 2016-01-08 18:37:54 +0000
4@@ -218,7 +218,8 @@
5 formatted_extra = ';'.join('{}: {}'.format(k, ','.join(v))
6 for k, v in res.json().get('extra', {}).items())
7 self.log.error(
8- 'Error %d getting SSO token %s: %s, %s',
9+ '[%s] Error %d getting SSO token %s: %s, %s',
10+ res.headers.get('x-request-id'),
11 res.status_code,
12 sso_url,
13 msg, formatted_extra)
14@@ -266,7 +267,8 @@
15 timeout=self.nw_timeout)
16 if r.status_code > 299:
17 self.log.error(
18- 'Error %d registering at %s: %s',
19+ '[%s] Error %d registering at %s: %s',
20+ r.headers.get('x-request-id'),
21 r.status_code,
22 self.register_url,
23 r.text)
24@@ -278,7 +280,9 @@
25 self.queue_url = urllib.parse.urljoin(self.server, href)
26 return True
27 except KeyError:
28- self.log.error("Malformed registration response: %s", r.json())
29+ self.log.error("[%s] Malformed registration response: %s",
30+ r.headers.get('x-request-id'),
31+ r.json())
32 return False
33 except requests.exceptions.ConnectionError as err:
34 self.log.error('Exception: %s', err)
35@@ -300,7 +304,8 @@
36 return False
37 elif r.status_code > 299:
38 self.log.error(
39- 'Error %d polling at %s: %s',
40+ '[%s] Error %d polling at %s: %s',
41+ r.headers.get('x-request-id'),
42 r.status_code,
43 self.queue_url,
44 r.text)
45@@ -379,7 +384,8 @@
46 timeout=self.nw_timeout)
47 if r.status_code > 299:
48 self.log.error(
49- 'Error %d posting result at %s: %s',
50+ '[%s] Error %d posting result at %s: %s',
51+ r.headers.get('x-request-id'),
52 r.status_code,
53 self.testresult_url,
54 r.text)
55
56=== modified file 'test_agent.py'
57--- test_agent.py 2015-12-04 22:54:58 +0000
58+++ test_agent.py 2016-01-08 18:37:54 +0000
59@@ -49,6 +49,8 @@
60 def text(self):
61 return self._text
62
63+ headers = {'x-request-id': 'foobar'}
64+
65
66 epoch = datetime.datetime(1970, 1, 1)
67

Subscribers

People subscribed via source and target branches

to all changes: