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

v3: Fix issue with default logger when creating RequestCtx #3134

Merged
merged 2 commits into from
Sep 15, 2024
Merged

Conversation

gaby
Copy link
Member

@gaby gaby commented Sep 14, 2024

Description

  • Use Noop Logger when creating RequestCtx for Adaptor Middleware.
  • Added benchmark for No Content.

Fixes #3130

  • Enhancement (improvement to existing features and functionality)

@gaby gaby added the v3 label Sep 14, 2024
@gaby gaby requested a review from a team as a code owner September 14, 2024 22:28
@gaby gaby requested review from sixcolors, ReneWerner87 and efectn and removed request for a team September 14, 2024 22:28
Copy link
Contributor

coderabbitai bot commented Sep 14, 2024

Walkthrough

The changes introduce a new disableLogger type that implements a no-operation logging method, which is used to suppress log outputs during request handling in the Fiber framework. This modification is made to prevent undesired logging when the application encounters errors, particularly when serving static content. Additionally, the test suite is updated to include cases for handling requests with no body content, improving the robustness of the tests.

Changes

Files Change Summary
middleware/adaptor/adaptor.go Added disableLogger type and Printf method to suppress logging during request context initialization.
middleware/adaptor/adaptor_test.go Enhanced tests with a new case for requests with no body content and updated benchmarks accordingly.

Assessment against linked issues

Objective Addressed Explanation
Expecting the Noop logger to be invoked, leading to no logs being written (#[3130])
Ensure that the logging behavior during request context initialization is controlled (#[3130])

Poem

In the meadow, where bunnies hop,
A logger's silence is quite the stop.
No more logs of files not found,
Just peaceful hops on soft, green ground.
With tests that check both near and far,
Our Fiber app shines like a star! 🌟🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai generate interesting stats about this repository and render them as a table.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Sep 14, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.19%. Comparing base (0ef8d71) to head (60e065a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
middleware/adaptor/adaptor.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3134      +/-   ##
==========================================
+ Coverage   80.13%   80.19%   +0.05%     
==========================================
  Files         117      117              
  Lines        9047     9048       +1     
==========================================
+ Hits         7250     7256       +6     
+ Misses       1363     1360       -3     
+ Partials      434      432       -2     
Flag Coverage Δ
unittests 80.19% <50.00%> (+0.05%) ⬆️

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5c1a0ce and c879135.

Files selected for processing (2)
  • middleware/adaptor/adaptor.go (2 hunks)
  • middleware/adaptor/adaptor_test.go (5 hunks)
Additional context used
GitHub Check: codecov/patch
middleware/adaptor/adaptor.go

[warning] 19-19: middleware/adaptor/adaptor.go#L19
Added line #L19 was not covered by tests

Additional comments not posted (3)
middleware/adaptor/adaptor.go (1)

17-20: LGTM!

The disableLogger type with an empty Printf method is a clean way to implement a no-op logger for suppressing unwanted logs. This aligns with the PR objective of preventing logs for missing static files.

Tools
GitHub Check: codecov/patch

[warning] 19-19: middleware/adaptor/adaptor.go#L19
Added line #L19 was not covered by tests

middleware/adaptor/adaptor_test.go (2)

89-89: LGTM!

Initializing the fasthttp.RequestCtx with a disabled logger in the test should help prevent unwanted logging of errors, aligning with the PR objective.


415-418: LGTM!

The changes to the benchmark functions to include a new case for handling requests with no body content look good. Creating an empty buffer when bodyContent is nil ensures that the case is handled correctly and prevents potential nil pointer dereferences. This improves the robustness of the benchmarks.

Also applies to: 457-464, 490-493, 531-539

middleware/adaptor/adaptor.go Show resolved Hide resolved
@ReneWerner87 ReneWerner87 added this to the v3 milestone Sep 15, 2024
Copy link
Member

@ReneWerner87 ReneWerner87 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: 60e065a Previous: 0ef8d71 Ratio
BenchmarkAppendMsgitem - MB/s 3220.88 MB/s 1834.64 MB/s 1.76
BenchmarkAppendMsgitem - MB/s 2876.25 MB/s 1834.64 MB/s 1.57

This comment was automatically generated by workflow using github-action-benchmark.

@ReneWerner87
Copy link
Member

BenchmarkAppendMsgitem

@gaby
image
there is the problem with the same names in different mw´s
can we rename ?

@ReneWerner87
Copy link
Member

same for other benches
image

@gaby should we do it in another PR ? then its separated

@gaby
Copy link
Member Author

gaby commented Sep 15, 2024

BenchmarkAppendMsgitem

@gaby image there is the problem with the same names in different mw´s can we rename ?

LOL! 😂 Yeah we should rename that, let do a commit here

@ReneWerner87 ReneWerner87 merged commit fbc24e8 into main Sep 15, 2024
15 of 17 checks passed
@gaby
Copy link
Member Author

gaby commented Sep 15, 2024

Actually those are auto generated

@gaby gaby deleted the fix-3130 branch September 15, 2024 17:46
@ReneWerner87
Copy link
Member

lets move this discussion to discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

🐛 [Bug]: FiberApp adaptor initializes fasthttp.RequestCtx with nil logger
2 participants