Skip to content

Commit

Permalink
pass X-Debug header downstream
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Davy committed Jan 20, 2020
1 parent a8bb6fb commit f5438d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions talisker/requests.py
Expand Up @@ -169,6 +169,8 @@ def send(request, **kwargs):
deadline = datetime.utcfromtimestamp(Context.current.deadline)
formatted = deadline.isoformat() + 'Z'
request.headers[config.deadline_header] = formatted
if Context.debug:
request.headers['X-Debug'] = '1'
try:
return func(request, **kwargs)
except Exception as e:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_requests.py
Expand Up @@ -223,6 +223,7 @@ def test_metric_hook_registered_endpoint(
def test_configured_session(context, get_breadcrumbs):
deadline = time.time() + 10
expected_deadline = datetime.utcfromtimestamp(deadline).isoformat() + 'Z'
Context.set_debug()
Context.current.deadline = deadline
session = requests.Session()
talisker.requests.configure(session)
Expand All @@ -242,6 +243,7 @@ def test_configured_session(context, get_breadcrumbs):
headers = responses.calls[0].request.headers
assert headers['X-Request-Id'] == 'XXX'
assert headers['X-Request-Deadline'] == expected_deadline
assert headers['X-Debug'] == '1'
assert context.statsd[0] == 'requests.count.localhost.view:1|c'
assert context.statsd[1].startswith(
'requests.latency.localhost.view.200:')
Expand Down

0 comments on commit f5438d5

Please sign in to comment.