feat: global context for logging #25920
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
We have a few examples in the codebase where for logging purposes we need to pass data down to parts of the codebase that have no need to know about this data. It creates very coupled and bloated modules that often are just passing data down without even acting on it. This change proposes the use of a global context dictionary that is used for read-only purposes for logging.
There are three places where we can use this functionality. One is an open PR that I wrote that helps us to log a report execution id to tie together multiple logs to the same report execution.
Another example is passing report header data to an smtp event for logging in a mail server.
And the third use case is to pass dashboard_id and chart_id into the sql mutator for logging.
I have rewritten the first two examples each in one commit in this PR for diffing the implementations for each with a global context. I'll add how the third example (sql mutator) either in this PR or in a subsequent one.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION