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

refactor: Started enforcing usage of structlog.stdlib.get_logger over logging.getLogger and banned use of the root logger #8470

Merged

Conversation

edgarrmondragon
Copy link
Collaborator

@edgarrmondragon edgarrmondragon commented Mar 28, 2024

Adds some consistency to our logs when not using one of the built-in meltano.core.logging formatters:

  • structlog uses an event key instead of message
  • structlog uses lower case for the log level
  • structlog can add context vars, so we could enrich more logs if we decide to e.g. add an environment= context var

TODO:

  • Address all logging.debug and similar calls?

Note

This doesn't address 3rd party library logs

Copy link

netlify bot commented Mar 28, 2024

Deploy Preview for meltano canceled.

Name Link
🔨 Latest commit ebe067e
🔍 Latest deploy log https://app.netlify.com/sites/meltano/deploys/6638f5e77beb820008007711

@edgarrmondragon edgarrmondragon force-pushed the edgarrmondragon/refactor/enforce-structlog-logging branch 5 times, most recently from d46e678 to be29f21 Compare March 28, 2024 02:00
Copy link

codecov bot commented Mar 28, 2024

Codecov Report

Attention: Patch coverage is 94.57364% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 91.78%. Comparing base (797f082) to head (ebe067e).

Files Patch % Lines
src/meltano/core/db.py 71.42% 2 Missing ⚠️
src/meltano/core/utils/pidfile.py 0.00% 2 Missing ⚠️
src/meltano/core/logging/job_logging_service.py 66.66% 1 Missing ⚠️
src/meltano/core/migration_service.py 75.00% 1 Missing ⚠️
tests/fixtures/db/mssql.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8470      +/-   ##
==========================================
+ Coverage   91.72%   91.78%   +0.06%     
==========================================
  Files         245      245              
  Lines       19323    19325       +2     
  Branches     2150     2149       -1     
==========================================
+ Hits        17724    17738      +14     
+ Misses       1324     1313      -11     
+ Partials      275      274       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@edgarrmondragon edgarrmondragon force-pushed the edgarrmondragon/refactor/enforce-structlog-logging branch 7 times, most recently from eb63317 to b1ec40b Compare April 3, 2024 04:08
@edgarrmondragon edgarrmondragon force-pushed the edgarrmondragon/refactor/enforce-structlog-logging branch 3 times, most recently from b3a3e56 to 6ebf029 Compare April 10, 2024 21:50
@edgarrmondragon edgarrmondragon force-pushed the edgarrmondragon/refactor/enforce-structlog-logging branch from 6ebf029 to c373e33 Compare April 29, 2024 20:32
@edgarrmondragon edgarrmondragon force-pushed the edgarrmondragon/refactor/enforce-structlog-logging branch from c373e33 to c972ad2 Compare April 29, 2024 20:38
@edgarrmondragon edgarrmondragon changed the title refactor: Started enforcing usage of structlog.stdlib.get_logger over logging.getLogger refactor: Started enforcing usage of structlog.stdlib.get_logger over logging.getLogger and banned use of the root logger May 3, 2024
@edgarrmondragon edgarrmondragon marked this pull request as ready for review May 3, 2024 18:49
@edgarrmondragon edgarrmondragon requested a review from a team as a code owner May 3, 2024 18:49
Copy link
Contributor

@pnadolny13 pnadolny13 left a comment

Choose a reason for hiding this comment

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

🚀

@edgarrmondragon edgarrmondragon merged commit 7574897 into main May 6, 2024
49 of 50 checks passed
@edgarrmondragon edgarrmondragon deleted the edgarrmondragon/refactor/enforce-structlog-logging branch May 6, 2024 15:42
github-merge-queue bot pushed a commit that referenced this pull request Jul 11, 2024
* Allow `install_plugins` call to optionally skip plugins that are already installed

* Make plugin install methods async

* Reuse existing skipped plugin install paradigm

* Implement for `invoke`

* Implement for `run`

* Remove all files in a plugin run dir, not including the dir itself

* POC: Disable install results output for `invoke`

* Fix `invoke` failing tests

* Address coverage warnings

* Implement for `el`/`elt`

* Default to showing plugin install status and results

* Implement for `test`

* Implement for `config <plugin> test`

* POC: Display installation state/progress as logs if a logger is provided - otherwise fallback to `click`

* Convert some CLI module logging to `structlog` to resolve mypy errors

Related to #8470

* Add `--[no-]install` option to all affected commands and reuse for `add`

* Update `install_plugins` patch

* Implement for `select --list`

* Use singular reason for just-in-time installs

* Use plugin fingerprint to determine if install is required

* Apply fixture to reset project context

* Prevent test failure when `VenvService` is instantiated more that once

* Safer to remove from explicit project root, rather than current working directory

* Ignore missing test coverage

Co-authored-by: Edgar Ramírez Mondragón <16805946+edgarrmondragon@users.noreply.github.com>

* Fix typing issues

* Apply suggestions from code review

Co-authored-by: Edgar Ramírez Mondragón <16805946+edgarrmondragon@users.noreply.github.com>

* Move plugin fingerprint read/write methods to `VirtualEnv`

* Fix `WPS214` error

* Add docs on `--[no-]install` usage for relevant commands

* Address missing coverage

* Do not require install if env vars are missing when expanding pip URL

* Warn user when auto-install will not be performed due to missing env var for plugin `pip_url`

* Update `skip_installed` kwarg  to more fitting `auto_install`

* Allow configuration of auto-install behaviour globally via env/`meltano.yml`

* Change `JIT` install reason to `AUTO`

* Use `AUTO` reason to indicate an auto-install, rather than explicit `auto_install` kwarg

* Prevent `'NoneType' object has no attribute 'settings'` error when running commands outside of a project

* Downgrade some install status/results logs to `DEBUG` when auto-installing

* Don't show "Installing" message for a plugin that will be skipped immediately after

* Update manifests

* Add schema entry for `auto_install`

---------

Co-authored-by: Edgar Ramírez Mondragón <16805946+edgarrmondragon@users.noreply.github.com>
Co-authored-by: Edgar Ramírez-Mondragón <edgar@meltano.com>
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.

3 participants