Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upProtect logging debug calls with isDebugEnabled to avoid performance penalties #1929
Comments
Description: Protect against potential performance degradation from debug logging by utilizing the logging libraries isDebugEnabled() check directly. Changes: * Protected all Logger.debug(...) calls with Logger.isDebugEnabled() Unit Tests: * N/A
Description: Protect against potential performance degradation from debug logging by utilizing the logging libraries isDebugEnabled() check directly. Changes: * Protected all Logger.debug(...) calls with Logger.isDebugEnabled() Unit Tests: * N/A
|
Thanks for the PR |
Describe the bug
Usually, debug logging is not enabled in production deployments. Sometimes the fields passed to debugging calls can take time to evaluate in order to utilize them in a debug message. These include resolving lists and maps to strings and , in some cases, certain get class name methods like getSimpleName, etc. In our usage of log4j, we found that some implementations offer lambda support to ensure that arguments used in the log4j calls are only evaluated if the debug level used is enabled. However, it looks like the logging implementation that graphql-java uses does not support this capability.
In performance testing our own GraphQL service, we found that relying on the logging implementations log level check was not enough because the method call still needs to evaluate the arguments passed to the Logger.debug method which incurs a cost.
To avoid any potentially incurred latency or performance degradation due to debug logging, all debug logging statements should be protected with isDebugEnabled.
To Reproduce
N/A