Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a request ID for all logs generated during request handling #354

Merged
merged 1 commit into from
Jan 30, 2020

Conversation

edaniszewski
Copy link
Contributor

This PR:

  • adds a request ID within the context of a request being processed, so all logs generated for the request will have the request ID associated with them, making it easier to tie log events to specific requests. this can be expanded upon in the future.

Example:

timestamp='2020-01-30T13:29:31.096917Z' logger='synse_server.api.http' level='debug' event='processing request' request_id='wfYy33jjFexsVFRbLjV7zj' method='GET' ip='172.18.0.1' path='/v3/plugin'
timestamp='2020-01-30T13:29:31.097165Z' logger='synse_server.cmd.plugin' level='info' event='issuing command' request_id='wfYy33jjFexsVFRbLjV7zj' command='PLUGINS'
timestamp='2020-01-30T13:29:31.097775Z' logger='sanic.access' level='info' event='' extra={'status': 200, 'byte': 236, 'host': '172.18.0.1:52010', 'request': 'GET http://localhost:5000/v3/plugin'}
timestamp='2020-01-30T13:29:35.008360Z' logger='synse_server.api.http' level='debug' event='processing request' request_id='nDs6XFxtGqR8ZsNCykj4MV' method='GET' ip='172.18.0.1' path='/v3/plugin'
timestamp='2020-01-30T13:29:35.008599Z' logger='synse_server.cmd.plugin' level='info' event='issuing command' request_id='nDs6XFxtGqR8ZsNCykj4MV' command='PLUGINS'
timestamp='2020-01-30T13:29:35.008946Z' logger='sanic.access' level='info' event='' extra={'status': 200, 'byte': 236, 'host': '172.18.0.1:52014', 'request': 'GET http://localhost:5000/v3/plugin'}
timestamp='2020-01-30T13:29:36.200119Z' logger='synse_server.api.http' level='debug' event='processing request' request_id='gGRM5xP8HZBP2cB9wUyBFL' method='GET' ip='172.18.0.1' path='/v3/plugin'
timestamp='2020-01-30T13:29:36.200417Z' logger='synse_server.cmd.plugin' level='info' event='issuing command' request_id='gGRM5xP8HZBP2cB9wUyBFL' command='PLUGINS'
timestamp='2020-01-30T13:29:36.200786Z' logger='sanic.access' level='info' event='' extra={'status': 200, 'byte': 236, 'host': '172.18.0.1:52018', 'request': 'GET http://localhost:5000/v3/plugin'}
timestamp='2020-01-30T13:30:04.919274Z' logger='synse_server.api.http' level='debug' event='processing request' request_id='jx5568Jw5kyjv4YaZaKUYM' method='GET' ip='127.0.0.1' path='/test'
timestamp='2020-01-30T13:30:04.919471Z' logger='synse_server.cmd.test' level='info' event='issuing command' request_id='jx5568Jw5kyjv4YaZaKUYM' command='TEST'
timestamp='2020-01-30T13:30:04.920018Z' logger='sanic.access' level='info' event='' extra={'status': 200, 'byte': 58, 'host': '127.0.0.1:49230', 'request': 'GET http://localhost:5000/test'}
timestamp='2020-01-30T13:31:04.979576Z' logger='synse_server.api.http' level='debug' event='processing request' request_id='NzR6DLN6oMhjr6TJ4njNPZ' method='GET' ip='127.0.0.1' path='/test'
timestamp='2020-01-30T13:31:04.979752Z' logger='synse_server.cmd.test' level='info' event='issuing command' request_id='NzR6DLN6oMhjr6TJ4njNPZ' command='TEST'
timestamp='2020-01-30T13:31:04.980202Z' logger='sanic.access' level='info' event='' extra={'status': 200, 'byte': 58, 'host': '127.0.0.1:49232', 'request': 'GET http://localhost:5000/test'}
timestamp='2020-01-30T13:31:05.784241Z' logger='synse_server.tasks' level='info' event='task: refreshing plugins' task='periodic plugin refresh' interval=120
timestamp='2020-01-30T13:31:05.784540Z' logger='synse_server.plugin' level='debug' event='refreshing plugin manager'
timestamp='2020-01-30T13:31:05.784767Z' logger='synse_server.plugin' level='info' event='loading plugins from configuration'

Note the request_id field in some of the messages.

@edaniszewski edaniszewski merged commit 34e3cb4 into v3/staging Jan 30, 2020
@edaniszewski edaniszewski deleted the v3/context-logging branch January 30, 2020 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant