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

Adjusted logs to be consistent across the code base #237

Merged
merged 2 commits into from
Feb 28, 2019

Conversation

jpkrohling
Copy link
Contributor

@jpkrohling jpkrohling commented Feb 27, 2019

Closes #203

Signed-off-by: Juraci Paixão Kröhling juraci@kroehling.de

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
@jpkrohling
Copy link
Contributor Author

This change is Reviewable

@codecov
Copy link

codecov bot commented Feb 28, 2019

Codecov Report

Merging #237 into master will decrease coverage by 0.34%.
The diff coverage is 93.82%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #237      +/-   ##
==========================================
- Coverage   90.19%   89.85%   -0.35%     
==========================================
  Files          61       62       +1     
  Lines        2753     2710      -43     
==========================================
- Hits         2483     2435      -48     
- Misses        172      177       +5     
  Partials       98       98
Impacted Files Coverage Δ
pkg/apis/io/v1alpha1/logger.go 0% <0%> (ø)
pkg/controller/jaeger/role.go 63.63% <100%> (-5.6%) ⬇️
pkg/controller/jaeger/configmap.go 63.63% <100%> (-5.6%) ⬇️
pkg/strategy/controller.go 100% <100%> (ø) ⬆️
pkg/controller/jaeger/rolebinding.go 63.63% <100%> (-5.6%) ⬇️
pkg/controller/jaeger/deployment.go 66.66% <100%> (-2.9%) ⬇️
pkg/controller/jaeger/route.go 63.63% <100%> (-5.6%) ⬇️
pkg/controller/jaeger/cronjob.go 63.63% <100%> (-5.6%) ⬇️
pkg/strategy/streaming.go 100% <100%> (ø) ⬆️
pkg/deployment/all-in-one.go 100% <100%> (ø) ⬆️
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 401ef74...adba5c3. Read the comment docs.

@@ -40,7 +40,10 @@ func (u *Config) Get() *v1.ConfigMap {
return nil
}

logrus.WithField("instance", u.jaeger.Name).Debug("Assembling the Sampling configmap")
log.WithFields(log.Fields{
Copy link
Member

Choose a reason for hiding this comment

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

I know that you have turned down my opinions but I find the current logging rather ad hoc. I am pretty suer sooner or later somebody will log something without proper fields.

I like static access to logger but in this case I would rather pass it explicitly or use MDC to for consistent logging and avoid repetition every time you access the logger. Another approach is to have a factory method creteLogger(j v1alpha1.Jaeger, tuples...) logger in utils package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

somebody will log something without proper fields

This happens already, as this PR shows: quite a few places had to be fixed to include the instance and/or namespace.

I'm not against using a base logger for the request-scoped code, but I don't quite like the idea of changing method signatures to include a logger which can be derived from the other parameters (log.WithFields("name": jaeger.Name, "namespace":jaeger.Namespace))

A helper like you proposed would certainly be something to consider, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a new commit in the direction of your suggestion. How does it look now?

Copy link
Member

Choose a reason for hiding this comment

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

it looks much better 👍

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
@pavolloffay
Copy link
Member

Does this resolve #203? My concert in #203 is that the log just says Reconciling.... and if the loop is invoked often like in OCP #231 it produces a high volume of logs with no valuable information.

I would expect it log something if there is a difference in desired state.

But this PR looks good it's definitelly an improvement.

@jpkrohling
Copy link
Contributor Author

At the debug level, I think the Reconciling... message is useful, to know that the loop has started. The fact that it shows up hundred of times should be considered a bug, which is handled by #231. In any case, it has now an execution field, so that we can correlate all log events for a given reconciliation loop.

I see #203 as a general "logging" issue, which is what this PR is solving.

I would expect it log something if there is a difference in desired state.

Hopefully done as part of #231 :-)

@jpkrohling jpkrohling merged commit f80e13f into jaegertracing:master Feb 28, 2019
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.

2 participants