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

chore: Improve and simplify logging #4194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

m-horky
Copy link
Contributor

@m-horky m-horky commented Aug 19, 2024

All Pull Requests:

Check all that apply:

  • Have you followed the guidelines in our Contributing document, including the instructions about commit messages?
  • Is this PR to correct an issue?
  • Is this PR an enhancement?

Complete Description of Additions/Changes:

  • Card ID: CCT-705

This patch will help us with identifying what is happening at given times.

  • Include phase, version and arguments on each phase load. Some of the information may not be necessary, as newer builds of insights-client contain logs that carry the information about phase and version. However, older builds do not, and these bits are valuable when debugging.
  • Disable logging of HTTP responses for collection rules and Inventory host. They are verbose and do not need to be logged in a file every time. The important parts of it are logged elsewhere.

@xiangce xiangce added the client These issues represent work to be done by the "client" team. label Aug 26, 2024
@m-horky m-horky force-pushed the better-logging branch 4 times, most recently from f5e1eee to e44e4be Compare August 29, 2024 11:00
insights/client/connection.py Show resolved Hide resolved
insights/client/connection.py Show resolved Hide resolved
insights/client/connection.py Outdated Show resolved Hide resolved
insights/client/connection.py Show resolved Hide resolved
@xiangce
Copy link
Contributor

xiangce commented Sep 5, 2024

Hi @m-horky - Sorry for bringing this trouble to you, as we just resolved an urgent bug within the repo. Please rebase the master branch of your fork of insights-core and then rebase this branch again. Please reach out to me for any problems when doing the rebase. Apologize again.

phase=os.getenv("INSIGHTS_PHASE", "unknown"),
version=package_info.get("VERSION", "unknown"),
path=client.__file__,
arguments=" ".join(sys.argv[1:]),
Copy link
Contributor

Choose a reason for hiding this comment

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

hm are you sure logging sys.argv is a good idea? it might contain credentials, eg --username and --password currently

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are not settable via CLI, only through the configuration file. Should we try to filter them anyways, in case someone enters it there by mistake?

insights/client/connection.py Show resolved Hide resolved
Copy link
Contributor

@ptoscano ptoscano left a comment

Choose a reason for hiding this comment

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

there's one small nit to potentially change, otherwise this LGTM

@xiangce please review as well, thanks!

insights/client/connection.py Outdated Show resolved Hide resolved
* Card ID: CCT-705

This patch will help us with identifying what is happening at given
times.

- Include phase, version and arguments on each phase load.
  Some of the information may not be necessary, as newer builds of
  insights-client contain logs that carry the information about phase
  and version. However, older builds do not, and these bits are valuable
  when debugging.

- Include payloads, headers and file attachments in the log message, if
  present. This should make it easier to debug PATCH calls.
  BASIC authentication credentials are not included in these headers,
  the library adds them later when constructing the request.

- Disable logging of HTTP responses for checkin. It is verbose and do
  not need to be logged in a file every time.

Signed-off-by: mhorky <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 11.11111% with 16 lines in your changes missing coverage. Please review.

Project coverage is 76.86%. Comparing base (7ff8c5e) to head (ed4aaff).

Files with missing lines Patch % Lines
insights/client/connection.py 5.88% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4194      +/-   ##
==========================================
- Coverage   76.88%   76.86%   -0.03%     
==========================================
  Files         757      757              
  Lines       41342    41354      +12     
  Branches     9526     9532       +6     
==========================================
  Hits        31785    31785              
- Misses       8479     8492      +13     
+ Partials     1078     1077       -1     
Flag Coverage Δ
unittests 76.83% <11.11%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@m-horky
Copy link
Contributor Author

m-horky commented Oct 1, 2024

Also please wait for our QE ACK before merging. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client These issues represent work to be done by the "client" team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants