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

util/log: rip out mostly defunct context logging, but make Logc family use trace #7914

Merged
merged 3 commits into from
Jul 19, 2016

Conversation

tbg
Copy link
Member

@tbg tbg commented Jul 19, 2016

This was a simple change but it removes a lot of cruft and makes us log to the trace whenever the Logc family of functions is used.

Some brave soul could comb the codebase and replace all uses of the Logf via Logc when there is a context around as this would make sure that everything that makes it to log files also makes it to an associated request's trace. We could even remove the Log(|f) family completely to force the more awkward log.Infoc(context.Background(), msg, args...).
#1779 goes a few steps further, but this seems like a good short-term goal.


This change is Reviewable

@petermattis
Copy link
Collaborator

I see a handful of places in the code where we're calling {Replica,Store}.context( and then log.{Level}c and expecting the log message to containing the {node,store,range} ID. For example:

        log.Fatalc(r.context(context.TODO()), "processRaftCommand requires a non-zero index")

I think adding r.String() as a prefix here is the correct change. I used the following grep to find the uses of {Store,Replica}.context(:

cd storage; git grep '\.context(' | grep -v _test.go

Review status: 0 of 11 files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from Reviewable

@tbg
Copy link
Member Author

tbg commented Jul 19, 2016

Good point, done (I ripped out .context() because well, it was kind of pointless at that stage, and won't be able to hold a trace).


Review status: 0 of 16 files reviewed at latest revision, all discussions resolved, some commit checks pending.


Comments from Reviewable

@petermattis
Copy link
Collaborator

:lgtm:


Review status: 0 of 16 files reviewed at latest revision, 1 unresolved discussion, some commit checks pending.


server/node.go, line 258 [r2] (raw file):

// String implements fmt.Stringer.
func (n *Node) String() string {
  return fmt.Sprintf("node %d", n.Descriptor.NodeID)

s/node %d/node=%d/g for symmetry with {Store,Replica}.String().


Comments from Reviewable

tbg added 2 commits July 19, 2016 13:10
Watching a test cluster, I found the replicate queue traces unsatisfying,
often lacking the crucial detail especially for failed replications.
@tbg
Copy link
Member Author

tbg commented Jul 19, 2016

Review status: 0 of 16 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


server/node.go, line 258 [r2] (raw file):

Previously, petermattis (Peter Mattis) wrote…

s/node %d/node=%d/g for symmetry with {Store,Replica}.String().

Done.

Comments from Reviewable

@tbg
Copy link
Member Author

tbg commented Jul 19, 2016

TFTR.

Curiously, go tool vet (via make check) locally didn't complain about the completely justified "possible formatting directive" in https://circleci.com/gh/tschottdorf/cockroach/2574). Any idea why that could be?

@petermattis
Copy link
Collaborator

Nope, no idea why it wouldn't fail locally as well.

@tbg tbg merged commit 30649b8 into cockroachdb:master Jul 19, 2016
@tbg tbg deleted the log-declutter branch July 19, 2016 17:52
@RaduBerinde
Copy link
Member

I don't really get what the plan is here. Having a context for what node we're on etc and having that show up in the log message is something we definitely need as we implement more multi-node tests. Is there a plan to replace the stuff that was there with something else?

@tbg
Copy link
Member Author

tbg commented Jul 21, 2016

Yes, #1779.

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