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

Review logging (dev and prod settings) #124

Merged
merged 2 commits into from
Jan 29, 2020
Merged

Review logging (dev and prod settings) #124

merged 2 commits into from
Jan 29, 2020

Conversation

samlesu
Copy link
Contributor

@samlesu samlesu commented Jan 24, 2020

  • add a log for each request done to the ledger
  • no more calls to root logger (logging.info(...)), use a module logger instead: it will allow better logging configuration and tuning
  • review dev settings for log configuration:
    • remove mail and file handlers: they are not used in dev mode
    • add substrapp logger
    • set custom configuration for external library when needed (hfc,
      celery, ...)
    • ensure all emitted logs to the console have the same formatters (in all services)
  • review prod settings for log configuration
    • remove unused handlers and formatters
    • update default formatter
  • add settings/env variables to:
    • disable SQL query logs
    • disable worker printing tuple workerspace

@samlesu samlesu changed the title logs all request to ledger logs all requests to ledger Jan 24, 2020
jmorel
jmorel previously approved these changes Jan 27, 2020
Copy link
Contributor

@jmorel jmorel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this should help greatly when debugging the platform. We'll need to decide what to do precisely with prod settings, but otherwise 👍

@samlesu
Copy link
Contributor Author

samlesu commented Jan 27, 2020

⚠️ Without printing SQL queries and without printing worker workspaces.

Prod examples

Without printing SQL queries and without printing worker workspaces:

server:

substra-backend INFO 2020-01-27 15:28:08,812 substrapp.ledger_utils 74 140549382207232 smartcontract query:queryCompositeAlgos; elaps=40.70ms; error=None
substra-backend [pid: 74|app: 0|req: 35/124] 10.1.3.150 () {46 vars in 767 bytes} [Mon Jan 27 15:28:08 2020] GET /composite_algo/ => generated 2757 bytes in 59 msecs (HTTP/1.1 200) 5 headers in 157 bytes (1 switches on core 1)
substra-backend [pid: 82|app: 0|req: 20/125] 10.1.3.150 () {48 vars in 769 bytes} [Mon Jan 27 15:28:08 2020] POST /api-token-auth/ => generated 79 bytes in 105 msecs (HTTP/1.1 200) 5 headers in 136 bytes (1 switches on core 0)
substra-backend INFO 2020-01-27 15:28:09,192 substrapp.ledger_utils 92 140549781981056 smartcontract query:queryAlgos; elaps=42.24ms; error=None
substra-backend [pid: 92|app: 0|req: 47/126] 10.1.3.150 () {46 vars in 747 bytes} [Mon Jan 27 15:28:09 2020] GET /algo/ => generated 10047 bytes in 59 msecs (HTTP/1.1 200) 5 headers in 158 bytes (1 switches on core 0)
substra-backend [pid: 82|app: 0|req: 21/127] 10.1.3.150 () {48 vars in 769 bytes} [Mon Jan 27 15:28:09 2020] POST /api-token-auth/ => generated 80 bytes in 107 msecs (HTTP/1.1 200) 5 headers in 136 bytes (1 switches on core 1)
substra-backend INFO 2020-01-27 15:28:09,546 substrapp.ledger_utils 74 140549781981056 smartcontract query:queryAggregateAlgos; elaps=29.43ms; error=None
substra-backend [pid: 74|app: 0|req: 36/128] 10.1.3.150 () {46 vars in 767 bytes} [Mon Jan 27 15:28:09 2020] GET /aggregate_algo/ => generated 4 bytes in 61 msecs (HTTP/1.1 200) 5 headers in 154 bytes (1 switches on core 0)
substra-backend [pid: 92|app: 0|req: 48/129] 10.1.3.150 () {48 vars in 769 bytes} [Mon Jan 27 15:28:09 2020] POST /api-token-auth/ => generated 80 bytes in 82 msecs (HTTP/1.1 200) 5 headers in 136 bytes (1 switches on core 1)
substra-backend INFO 2020-01-27 15:28:09,809 substrapp.ledger_utils 82 140549781981056 smartcontract query:queryAggregatetuples; elaps=19.53ms; error=None
substra-backend [pid: 82|app: 0|req: 22/130] 10.1.3.150 () {46 vars in 767 bytes} [Mon Jan 27 15:28:09 2020] GET /aggregatetuple/ => generated 4 bytes in 31 msecs (HTTP/1.1 200) 5 headers in 154 bytes (1 switches on core 0)
substra-backend [pid: 74|app: 0|req: 37/131] 10.1.3.150 () {48 vars in 769 bytes} [Mon Jan 27 15:28:09 2020] POST /api-token-auth/ => generated 80 bytes in 76 msecs (HTTP/1.1 200) 5 headers in 136 bytes (1 switches on core 1)
substra-backend INFO 2020-01-27 15:28:10,082 substrapp.ledger_utils 74 140549781981056 smartcontract query:queryCompositeAlgos; elaps=28.17ms; error=None
substra-backend [pid: 74|app: 0|req: 38/132] 10.1.3.150 () {46 vars in 767 bytes} [Mon Jan 27 15:28:10 2020] GET /composite_algo/ => generated 2757 bytes in 54 msecs (HTTP/1.1 200) 5 headers in 157 bytes (1 switches on core 0)

Note: the different log formats for the requests/apps is due to the usage of uwsgi.

worker

INFO 2020-01-27 15:27:45,342 substrapp.tasks.tasks 33 139625782822720 Prepare materials for traintuple task
INFO 2020-01-27 15:27:45,383 substrapp.ledger_utils 33 139625782822720 smartcontract query:queryAlgo; elaps=22.49ms; error=None
INFO 2020-01-27 15:27:45,713 substrapp.tasks.tasks 33 139625782822720 Prepare materials for traintuple task: success
INFO 2020-01-27 15:27:46,798 substrapp.tasks.utils 33 139625782822720 [traintuple_ab1f2522_train] Traceback (most recent call last):
INFO 2020-01-27 15:27:46,798 substrapp.tasks.utils 33 139625782822720 [traintuple_ab1f2522_train]   File "algo.py", line 30, in <module>
INFO 2020-01-27 15:27:46,798 substrapp.tasks.utils 33 139625782822720 [traintuple_ab1f2522_train]     raise Exception("Intentionally keep on failing until we have failed 2 time(s). The algo has now             failed " + str(counter) + " time(s).")
INFO 2020-01-27 15:27:46,798 substrapp.tasks.utils 33 139625782822720 [traintuple_ab1f2522_train] Exception: Intentionally keep on failing until we have failed 2 time(s). The algo has now             failed 1 time(s).
INFO 2020-01-27 15:27:46,799 substrapp.tasks.utils 33 139625782822720 [traintuple_ab1f2522_train]
INFO 2020-01-27 15:27:46,832 substrapp.tasks.tasks 33 139625782822720 Remove subtuple materials
INFO 2020-01-27 15:27:50,077 substrapp.tasks.tasks 33 139625782822720 Prepare materials for traintuple task

Dev examples

server

substra-backend INFO - 2020-01-27 15:34:16,261 - substrapp.ledger_utils - smartcontract invoke:registerDataSample; elaps=87.13ms; error=None
substra-backend INFO - 2020-01-27 15:34:16,277 - django.server - "POST /data_sample/ HTTP/1.1" 201 200
substra-backend INFO - 2020-01-27 15:34:16,490 - substrapp.ledger_utils - smartcontract query:createTraintuple; elaps=22.37ms; error=None
substra-backend INFO - 2020-01-27 15:34:16,564 - events.apps - Processing task 0543d7b8a532211c60176cb826d908da3b3716768191194f00e96fec67792699: type=traintuple status=todo
substra-backend INFO - 2020-01-27 15:34:16,584 - substrapp.ledger_utils - smartcontract invoke:createTraintuple; elaps=93.47ms; error=None
substra-backend INFO - 2020-01-27 15:34:16,586 - django.server - "POST /traintuple/ HTTP/1.1" 201 77
substra-backend INFO - 2020-01-27 15:34:16,643 - substrapp.ledger_utils - smartcontract query:queryTraintuple; elaps=33.06ms; error=None
substra-backend INFO - 2020-01-27 15:34:16,646 - django.server - "GET /traintuple/0543d7b8a532211c60176cb826d908da3b3716768191194f00e96fec67792699/ HTTP/1.1" 200 784
substra-backend INFO - 2020-01-27 15:34:17,199 - substrapp.ledger_utils - smartcontract query:queryTraintuple; elaps=28.44ms; error=None
substra-backend INFO - 2020-01-27 15:34:17,200 - django.server - "GET /traintuple/0543d7b8a532211c60176cb826d908da3b3716768191194f00e96fec67792699/ HTTP/1.1" 200 785
substra-backend INFO - 2020-01-27 15:34:17,756 - substrapp.ledger_utils - smartcontract query:queryTraintuple; elaps=40.00ms; error=None
substra-backend INFO - 2020-01-27 15:34:17,761 - django.server - "GET /traintuple/0543d7b8a532211c60176cb826d908da3b3716768191194f00e96fec67792699/ HTTP/1.1" 200 785

worker

INFO - 2020-01-27 15:33:42,507 - substrapp.ledger_utils - smartcontract invoke:logStartTrain; elaps=68.53ms; error=None
INFO - 2020-01-27 15:33:42,538 - substrapp.tasks.tasks - Prepare materials for traintuple task
INFO - 2020-01-27 15:33:42,574 - substrapp.ledger_utils - smartcontract query:queryAlgo; elaps=24.69ms; error=None
INFO - 2020-01-27 15:33:42,932 - substrapp.ledger_utils - smartcontract query:queryModelDetails; elaps=39.66ms; error=None
INFO - 2020-01-27 15:33:43,187 - substrapp.ledger_utils - smartcontract query:queryModelDetails; elaps=25.91ms; error=None
INFO - 2020-01-27 15:33:43,423 - substrapp.tasks.tasks - Prepare materials for traintuple task: success
INFO - 2020-01-27 15:33:44,272 - substrapp.tasks.utils - [traintuple_edea3b8a_train]
INFO - 2020-01-27 15:33:44,307 - substrapp.tasks.tasks - Remove subtuple materials

@samlesu samlesu marked this pull request as ready for review January 27, 2020 15:36
@samlesu samlesu changed the title logs all requests to ledger Review logging (dev and prod settings) Jan 27, 2020
jmorel
jmorel previously approved these changes Jan 28, 2020
Copy link
Contributor

@jmorel jmorel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm more than fine with the changes, but maybe someone who participated in creating the previous conf should weigh in.

@Kelvin-M
Copy link
Contributor

Need to be rebased @samlesu

- add a log for each request done to the ledger
- no more calls to root logger (logging.info(...)), use a module logger
  instead: it will allow better logs configuration and tuning
- review debug log configuration:
  - remove mail and file handlers: they are not used in dev mode
  - add substrapp logger
  - set custom configuration for external library when needed (hfc,
  celery, ...)
- add settings/env variables to:
  - disable SQL query logss
  - disable worker printing tuple workerspace
- remove unused handlers
@samlesu
Copy link
Contributor Author

samlesu commented Jan 29, 2020

Need to be rebased @samlesu

Thanks, done.

@Kelvin-M
Copy link
Contributor

I let you merge if you think it's the log level you need to debug :)

@samlesu
Copy link
Contributor Author

samlesu commented Jan 29, 2020

I let you merge if you think it's the log level you need to debug :)

Could you be more precise? Do you think we should increase or decrease some logger levels in dev or prod settings ?

@Kelvin-M
Copy link
Contributor

Nope, all I mean is, if you do not need to make any change to the log level feel free to merge ! I don't know if you're still ajusting the log level :)

@samlesu
Copy link
Contributor Author

samlesu commented Jan 29, 2020

Nope, all I mean is, if you do not need to make any change to the log level feel free to merge ! I don't know if you're still ajusting the log level :)

Thanks for the clarification ! I think this PR is great start to improve our logs in dev and production. It will have to be updated according to our needs. I will be happy to merge once I have an approval from either you, @inalgnu, or @GuillaumeCisco before merging.

Copy link
Member

@inelgnu inelgnu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @samlesu 👍

@samlesu samlesu merged commit 5b784a4 into master Jan 29, 2020
@@ -182,6 +182,8 @@ def container_format_log(container_name, container_logs):


def list_files(startpath):
if not settings.TASK['LIST_WORKSPACE']:
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should never return nothing.
Why not simply use if settings.TASK['LIST_WORKSPACE']:

backend/backend/settings/common.py Show resolved Hide resolved
@samlesu samlesu deleted the logs-and-logs branch January 29, 2020 13:37
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.

5 participants