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: refactor log #1008

Merged
merged 7 commits into from
Aug 24, 2023
Merged

Conversation

binbin-li
Copy link
Collaborator

@binbin-li binbin-li commented Aug 21, 2023

Description

What this PR does / why we need it:

  1. Add an internal logger util that initializes logger for Ratify and configures the context with trace-id either from requests or auto-generated.
  2. Refactor Executor, Server and Store to use this logger util instead of Logrus directly.
  3. Add formatter and requestHeaders to the helm chart value so that users can configure the logger.
  4. Add a doc for logger.

This is the first PR which just introduced the basic new logging framework to Ratify. There will be a following PR that refactors most logging lines to use the new logger util.

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):

Fixes #972 #963

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Helm Chart Change (any edit/addition/update that is necessary for changes merged to the main branch)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration
Added unit tests.
A screenshot of local testing, all logs within a request have the same trace-id and have component-type set as well.
image

Checklist:

  • Does the affected code have corresponding tests?
  • Are the changes documented, not just with inline documentation, but also with conceptual documentation such as an overview of a new feature, or task-based documentation like a tutorial? Consider if this change should be announced on your project blog.
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have appropriate license header?

Post Merge Requirements

  • MAINTAINERS: manually trigger the "Publish Package" workflow after merging any PR that indicates Helm Chart Change

@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

Patch coverage: 66.36% and project coverage change: +0.16% 🎉

Comparison is base (85a5803) 58.16% compared to head (aa5776a) 58.32%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1008      +/-   ##
==========================================
+ Coverage   58.16%   58.32%   +0.16%     
==========================================
  Files          91       92       +1     
  Lines        5448     5529      +81     
==========================================
+ Hits         3169     3225      +56     
- Misses       1965     1989      +24     
- Partials      314      315       +1     
Files Changed Coverage Δ
cmd/ratify/cmd/discover.go 17.64% <0.00%> (-0.54%) ⬇️
cmd/ratify/cmd/referrer.go 29.13% <0.00%> (-0.60%) ⬇️
cmd/ratify/cmd/resolve.go 32.65% <0.00%> (-2.13%) ⬇️
cmd/ratify/cmd/serve.go 38.09% <0.00%> (-4.77%) ⬇️
cmd/ratify/cmd/verify.go 61.84% <0.00%> (-2.55%) ⬇️
cmd/ratify/main.go 25.00% <ø> (-37.50%) ⬇️
config/config.go 51.89% <0.00%> (-4.27%) ⬇️
pkg/referrerstore/oras/oras.go 69.03% <44.44%> (+0.20%) ⬆️
pkg/executor/core/executor.go 89.00% <50.00%> (ø)
httpserver/handlers.go 74.61% <66.66%> (+0.26%) ⬆️
... and 2 more

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

@binbin-li binbin-li marked this pull request as draft August 21, 2023 08:21
@binbin-li binbin-li force-pushed the refactor-log branch 2 times, most recently from b798924 to 55f86d1 Compare August 21, 2023 09:11
Copy link
Collaborator

@susanshi susanshi left a comment

Choose a reason for hiding this comment

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

left some suggestion around documentation. thanks!

docs/reference/logger.md Outdated Show resolved Hide resolved
docs/reference/logger.md Outdated Show resolved Hide resolved
docs/reference/logger.md Show resolved Hide resolved
cmd/ratify/cmd/serve.go Outdated Show resolved Hide resolved
internal/logger/logger.go Outdated Show resolved Hide resolved
@binbin-li binbin-li force-pushed the refactor-log branch 2 times, most recently from df0545f to 438467b Compare August 22, 2023 13:33
Copy link
Collaborator

@FeynmanZhou FeynmanZhou left a comment

Choose a reason for hiding this comment

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

PTAL

docs/reference/logger.md Show resolved Hide resolved
docs/reference/logger.md Outdated Show resolved Hide resolved
susanshi
susanshi previously approved these changes Aug 23, 2023
Copy link
Collaborator

@susanshi susanshi left a comment

Choose a reason for hiding this comment

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

Looks good to me. thanks binbin!

Makefile Show resolved Hide resolved
@binbin-li binbin-li force-pushed the refactor-log branch 2 times, most recently from c2d02ed to 1704895 Compare August 24, 2023 05:38
@binbin-li binbin-li merged commit c5da630 into ratify-project:main Aug 24, 2023
15 checks passed
junczhu pushed a commit to ZAFT-Armored-Keeper-of-Unity/ratify that referenced this pull request Aug 25, 2023
Signed-off-by: Yi Zha <yizha1@microsoft.com>

chore: update constraint templates

refactor: refactor log (ratify-project#1008)

fix: display cert store status (ratify-project#1021)

Co-authored-by: Binbin Li <libinbin@microsoft.com>

chore: update constraint templates
@junczhu junczhu mentioned this pull request Aug 25, 2023
12 tasks
bspaans pushed a commit to bspaans/ratify that referenced this pull request Oct 17, 2023
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.

ratify logs should provide better filtering support
4 participants