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

Added Zap as the default Error log #11820 #11830

Closed

Conversation

tarun-kavipurapu
Copy link

Description

This Issue Fixes the Issue #11820
Fixes

  • Made the Zap as the default ErrorLog Supplied to the Http server

@tarun-kavipurapu tarun-kavipurapu requested a review from a team as a code owner December 9, 2024 18:41
Copy link

linux-foundation-easycla bot commented Dec 9, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Comment on lines 483 to 491
// Setting the server error logger
logger := zap.NewStdLog(settings.Logger)
server := &http.Server{
Handler: handler,
ReadTimeout: hss.ReadTimeout,
ReadHeaderTimeout: hss.ReadHeaderTimeout,
WriteTimeout: hss.WriteTimeout,
IdleTimeout: hss.IdleTimeout,
ErrorLog: logger,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Setting the server error logger
logger := zap.NewStdLog(settings.Logger)
server := &http.Server{
Handler: handler,
ReadTimeout: hss.ReadTimeout,
ReadHeaderTimeout: hss.ReadHeaderTimeout,
WriteTimeout: hss.WriteTimeout,
IdleTimeout: hss.IdleTimeout,
ErrorLog: logger,
server := &http.Server{
Handler: handler,
ReadTimeout: hss.ReadTimeout,
ReadHeaderTimeout: hss.ReadHeaderTimeout,
WriteTimeout: hss.WriteTimeout,
IdleTimeout: hss.IdleTimeout,
// Setting the server error logger
ErrorLog: zap.NewStdLog(settings.Logger),

@bogdandrutu
Copy link
Member

Please sign the CLA

@tarun-kavipurapu
Copy link
Author

tarun-kavipurapu commented Dec 10, 2024

@bogdandrutu Made the desired Changes snd signed the CLA

@atoulme
Copy link
Contributor

atoulme commented Dec 11, 2024

Please add a changelog.

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.59%. Comparing base (cef6ce5) to head (ebcc31e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11830   +/-   ##
=======================================
  Coverage   91.59%   91.59%           
=======================================
  Files         449      449           
  Lines       23761    23763    +2     
=======================================
+ Hits        21763    21765    +2     
  Misses       1623     1623           
  Partials      375      375           

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

@tarun-kavipurapu
Copy link
Author

@atoulme change log added

@@ -479,13 +481,14 @@ func (hss *ServerConfig) ToServer(_ context.Context, host component.Host, settin
next: handler,
includeMetadata: hss.IncludeMetadata,
}

errorLog, _ := zap.NewStdLogAt(settings.Logger, zapcore.ErrorLevel)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we return the error?

Copy link
Author

Choose a reason for hiding this comment

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

I dont think so because if errLog is nil in http.Server it will default to standard logger but if we return the error it may disrupt the entire flow In jaeger also similar pattern is followed
https://github.com/jaegertracing/jaeger/blob/8f612a876dc501e0db9786a054ff52fee314afb3/cmd/collector/app/server/http.go#L47

Copy link
Member

Choose a reason for hiding this comment

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

it's fine to return the error, but the error handling won't be tested because the error will never happen - it only happens if the 2nd argument is not a valid log level, e.g. zapcore.Level(123)

Copy link
Author

Choose a reason for hiding this comment

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

sure then will make a change returning the error

Copy link
Contributor

Choose a reason for hiding this comment

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

it only matters if zap changes its internals moving forward, and since we're returning an error anyway, might as well return it.

Copy link
Author

Choose a reason for hiding this comment

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

Hey Just a small question Unrelated to this
I want to contribute to the OpenTelemetry ecosystem actively. Which repositories would be most suitable for someone at a beginner level to start contributing effectively?

Copy link
Contributor

Choose a reason for hiding this comment

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

that depends what you like to work on and what you need to get out of the project. Consider joining the CNCF slack and our SIG meetings to get involved.

@codeboten codeboten added this pull request to the merge queue Dec 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 14, 2024
@dmitryax dmitryax closed this Dec 14, 2024
@dmitryax dmitryax reopened this Dec 14, 2024
@dmitryax dmitryax enabled auto-merge December 14, 2024 17:01
@dmitryax dmitryax added this pull request to the merge queue Dec 14, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 14, 2024
@dmitryax
Copy link
Member

@tarun-kavipurapu can you please try to resubmit the PR?

@tarun-kavipurapu
Copy link
Author

@dmitryax is this what you mean by resubmitting PR or do you want me to create a new PR

@dmitryax dmitryax added this pull request to the merge queue Dec 15, 2024
github-merge-queue bot pushed a commit that referenced this pull request Dec 15, 2024
#### Description
This Issue Fixes the Issue #11820 
Fixes 
- Made the Zap as the default ErrorLog Supplied to the Http server

---------

Co-authored-by: Alex Boten <[email protected]>
@dmitryax
Copy link
Member

dmitryax commented Dec 15, 2024

@tarun-kavipurapu I meant creating another PR, but I can try merging this one again

@tarun-kavipurapu
Copy link
Author

@dmitryax sure if this one fails i will create a new pr

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 15, 2024
@mx-psi mx-psi enabled auto-merge December 16, 2024 08:50
@mx-psi mx-psi added this pull request to the merge queue Dec 16, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 16, 2024
@mx-psi mx-psi closed this Dec 16, 2024
@mx-psi mx-psi reopened this Dec 16, 2024
@mx-psi mx-psi enabled auto-merge December 16, 2024 10:25
@mx-psi mx-psi added this pull request to the merge queue Dec 16, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 16, 2024
@dmitryax
Copy link
Member

@tarun-kavipurapu, it's still failing. Can you please try opening another PR?

@tarun-kavipurapu
Copy link
Author

tarun-kavipurapu commented Dec 16, 2024

@dmitryax ya will do that and link the pr number here sorry i was a little busy today

@tarun-kavipurapu
Copy link
Author

Made a new Pr here #11935

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.

7 participants