Skip to content

Conversation

smacker
Copy link
Contributor

@smacker smacker commented Aug 8, 2018

Fix: #112

I have inspected the source code and found only a few places where logs (at least without context) make sense.
Looks like anything else even with debug level would just pollute output.

More verbose debug information will be helpful only if the log is scoped to request/event.

Signed-off-by: Maxim Sukharev <maxim@sourced.tech>
@smacker smacker requested review from carlosms and bzz August 8, 2018 17:15
@@ -53,6 +54,8 @@ func (s *Syncer) Sync(ctx context.Context,
}

func (s *Syncer) fetch(ctx context.Context, repoURL string, r *git.Repository, refspecs []config.RefSpec) error {
log.Infof("fetching references for repository %s: %v", repoURL, refspecs)
Copy link
Contributor

@bzz bzz Aug 9, 2018

Choose a reason for hiding this comment

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

As this process might take some time, do you think it might make sense to add another log to this function at the end of fetching?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

example of the logs

$ make dry-run
go run cmd/lookout/*.go serve --dry-run github.com/src-d/lookout
[2018-08-09T16:08:24.187459705+02:00]  INFO Starting watcher urls=[github.com/src-d/lookout]
[2018-08-09T16:08:24.190722352+02:00]  INFO connection state changed to 'READY' addr=ipv4://localhost:10302 analyzer=Dummy
[2018-08-09T16:08:27.589335009+02:00]  INFO event successfully processed, skipping... event-id=a29ea85b92358e61e3a56281c5f6e885fa170ab7 event-type=2
[2018-08-09T16:08:27.7994484+02:00]  INFO processing push app=lookout head=refs/heads/master provider=github repository=git://github.com/src-d/lookout.git
[2018-08-09T16:08:27.799639533+02:00]  INFO creating local repository for: git://github.com/src-d/lookout.git app=lookout
[2018-08-09T16:08:27.801553032+02:00]  INFO fetching references for repository git://github.com/src-d/lookout.git: [refs/heads/master:refs/heads/master] app=lookout
[2018-08-09T16:08:39.005883394+02:00]  INFO repository config is not found app=lookout head=refs/heads/master provider=github repository=git://github.com/src-d/lookout.git
[2018-08-09T16:08:39.005989076+02:00]  INFO status: pending app=lookout
[2018-08-09T16:08:39.006093794+02:00]  INFO unary client call started app=lookout grpc.method=NotifyPushEvent grpc.service=pb.Analyzer span.kind=client system=grpc

you can clearly see when it finished fetching. Imo that is more than enough for logs.
Or do you want to know how much time did it take? Should it be in the logs or in tracing?

Copy link
Contributor

@bzz bzz Aug 10, 2018

Choose a reason for hiding this comment

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

Or do you want to know how much time did it take?

yes, was thinking that could be easy way to see elapsed time in debug, until we have a tracing

Copy link
Contributor

@bzz bzz left a comment

Choose a reason for hiding this comment

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

SGTM.

Elapsed time for fetching would be nice to have on debug level

@smacker
Copy link
Contributor Author

smacker commented Aug 10, 2018

added. Please check @bzz @carlosms

start := time.Now()
defer func() {
if err == nil {
log.Debugf("references %v fetched for repository %s in %v", repoURL, refspecs, time.Now().Sub(start))
Copy link
Contributor

Choose a reason for hiding this comment

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

should we use log with field duration, to follow the guide conventions more closely?

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 think for debug logs it doesn't make much sense. Debug level shouldn't be enabled in production. Though I'm changing it just for the sake of consistency with other log messages.

Signed-off-by: Maxim Sukharev <maxim@sourced.tech>
@smacker smacker merged commit d7914de into src-d:master Aug 10, 2018
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.

3 participants