Cosmos Diagnostics Logging Filters and optimizations.#39897
Cosmos Diagnostics Logging Filters and optimizations.#39897bambriz merged 16 commits intoAzure:mainfrom
Conversation
Adds the ability to use logging.Filters on diagnostics logs based on the same filterable parameters as the cosmos diagnostics handler. Also adds some optimizations to reduce time spent on logging diagnostics. Lastly improves the formatting of the diagnostics log to improve readabilty especially when errors are logged.
|
API change check APIView has identified API level changes in this PR and created following API reviews. |
simorenoh
left a comment
There was a problem hiding this comment.
Awesome, thanks Bryan!
Main thing I'd like though, is to add something similar to your PR description to the README section that talks about diagnostics in the SDK since this is highly relevant and probably the only way that customers will realistically use the logging since otherwise it's too verbose. Adding a section below with explanations on the two different ways to filter as well as links to the relevant samples would be great.
There was a problem hiding this comment.
LGTM. One suggestion would be to lower the amount of headers we log by default. For example these headers, I don't how much value they have for debugging.
'Server': 'Microsoft-HTTPAPI/2.0'
'Access-Control-Allow-Origin': ''
'Access-Control-Allow-Credentials': 'REDACTED'
'Transfer-Encoding': 'chunked'
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_http_logging_policy.py
Outdated
Show resolved
Hide resolved
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_http_logging_policy.py
Outdated
Show resolved
Hide resolved
This removes the custom diagnostics handler and instead allows the use of logging filters.
FabianMeiswinkel
left a comment
There was a problem hiding this comment.
I thik the perf results in the PR description are not very helpful - to understand the impact it would be required to udnerstand how much of the improvement is because logs are filtered out now? So, instead having two perf tests - one with high percentage of requetss really being logged. And one where the percentage of records being actually logged is extremely low (could even be zero) would be important.
Last-but-not-least - throughput would be good - Like how many point reads per second can be done with each of the models - with reference to CPU - to ensure that better throughput is not explained by just higher CPU.
simorenoh
left a comment
There was a problem hiding this comment.
minor comment on expanding the test but this looks great, thanks Bryan!
sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_diagnostics_handler.py
Outdated
Show resolved
Hide resolved
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_http_logging_policy.py
Outdated
Show resolved
Hide resolved
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_http_logging_policy.py
Outdated
Show resolved
Hide resolved
kushagraThapar
left a comment
There was a problem hiding this comment.
Thanks @bambriz, looks good to me.
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
* Updates on Cosmos Diagnostics Adds the ability to use logging.Filters on diagnostics logs based on the same filterable parameters as the cosmos diagnostics handler. Also adds some optimizations to reduce time spent on logging diagnostics. Lastly improves the formatting of the diagnostics log to improve readabilty especially when errors are logged. * Update CHANGELOG.md * Update CHANGELOG.md * updates to cosmos diagnostics * update to logging policy and tests * pylint updates * Update README.md * Remove diagnostics handler This removes the custom diagnostics handler and instead allows the use of logging filters. * Update CHANGELOG.md * Update _cosmos_http_logging_policy.py * update recommended changes * updates
Description:
This PR adds the ability to use Filters from the Logging Module to filter Cosmos Diagnostics Logs based on the same filterable parameters as the Cosmos Diagnostics Handler. The Cosmos Diagnostics Filterable parameters are added to the Log Record of the Logger used to log diagnostics.
Each log can be filtered by the following attributes:
status_codesub_status_codedurationverbdatabase_namecollection_nameoperation_typeurlresource_typeis_requestexample of using Filters to filter diagnostics logs:
Additionally, this PR adds some optimizations to significantly reduce the time spent on logging diagnostics. The improvement is more noticeable when large amounts of requests are logged. As a reference If using the old diagnostics for logging 5000 requests, the time spent on logging diagnostics was over 10000 ms, while with the new optimizations, the time spent is reduced to between 3000-5000ms if using the same filterable parameters.
See the following profiles of old diagnostics logging and new diagnostics logging while making 3600 requests:
The logs have also change in format to make the error messages more readable, as well as added some more diagnostic information. Formerly redacted headers are also now simply omitted to optimize logging.
Example: