-
Notifications
You must be signed in to change notification settings - Fork 516
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
Per Tenant Logging - Complete Implementation #2425
Per Tenant Logging - Complete Implementation #2425
Conversation
fde3a09
to
1f98af3
Compare
I'm not terribly fond of this approach. In order to keep it going, we have to remember to get a logger instance with a profile which adds overhead to a task that should incur as little overhead as possible -- if not at execution time, it at least adds overhead in code. This means more lines of code that maintainers need to scan through to find issues. So here's my suggestion: can we use context variables and a custom log formatter that reads a wallet_id context var to retrieve the wallet id (or any other subwallet specific values) when it's available? |
@dbluhm Based on your feedback, I have reworked the logging mechanism. I added |
What throws me off with this implementation is there is now a "special" way the get a "special" logger, rather than one consistent way to get a logger. A developer needs to be conscious of which logger they are using in a given context in order to have the desired behavior. It would be better if the implementation was more compatible with the built in logging functionality so it would be completely transparent to the developer. So the implementation may consist of a custom log handler and a custom log formatter. I believe this is inline with @dbluhm's suggestion of a custom log formatter. |
@WadeBarnes The reworked implementation adds a conditional to the existing app configuration to configure logger here:
Re Does this address your concerns? |
It's the calls to From the compatibility standpoint I was thinking an implementation that was more compatible with the logging.config.dictConfig(), where the logging configuration could be "defined" rather than "coded". This would help clean up |
This comment was marked as outdated.
This comment was marked as outdated.
I'm not super familiar with extending logging in python, but per-tenant logging, on the surface, to me, feels like an extension to the built in file log handler (or RotatingFileHandler) that collects the additional context and writes to individual files (one for each tenant), or a custom log formatter that collects and writes the additional context. In the case of the custom log formatter, it would be configured on a file log handler which is configured to write to a dynamic set of files (one for each tenant). |
For example, in aries_cloudagent/connections/base_manager.py, the wallet_id will only be known once |
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
d678ad4
to
8e9b0f2
Compare
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
…t-python into per_tenant_logging
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
@WadeBarnes @esune This is ready for review, all changes requested should be incorporated now [incl |
Let’s get this reviewed and merged in the next few days. Causing grief in debugging in multi-tenant worlds. Thanks! |
@esune, @loneil, @shaangill025, @swcurran, I've created a ore release image for this PR if you'd like to test it out with a traction instance; https://github.com/hyperledger/aries-cloudagent-python/pkgs/container/aries-cloudagent-python/134985613?tag=py3.9-0.11.0-pr2425-pre0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking a lot better than the first pass 🙂
I added a couple comments/questions, but other than that it looks good to me. If @dbluhm and/or @usingtechnology want to give it a look as they are more frequently involved in code changes for ACA-Py it would be great.
LOG_FORMAT_FILE_ALIAS_PATTERN = ( | ||
"%(asctime)s %(wallet_id)s %(levelname)s %(pathname)s:%(lineno)d %(message)s" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like the same pattern/variable that is held in default_per_tenant_logging_config.ini
- any reason to have the setting it repeated here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used in the following conditional code, where --log-file
is provided and --multitenant
enabled but no file handler is specified in a custom config (different from default):
https://github.com/hyperledger/aries-cloudagent-python/blob/1fd858763897039b39815a110e4417ce67f48763/aries_cloudagent/config/logging.py#L136
Signed-off-by: Shaanjot Gill <gill.shaanjots@gmail.com>
…t-python into per_tenant_logging
…aries-cloudagent-python into per_tenant_logging
Kudos, SonarCloud Quality Gate passed! |
@esune, @loneil, @shaangill025, @swcurran, A new pre release image for this PR has been created; https://github.com/hyperledger/aries-cloudagent-python/pkgs/container/aries-cloudagent-python/137906897?tag=py3.9-0.11.0-pr2425-pre1 |
Closing this PR and opening #2550 due to an issue with legacy (removed) code being in the pre-release images. |
resolve #2359