-
Notifications
You must be signed in to change notification settings - Fork 229
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
feat(*): more comprehensive log output #198
Conversation
The log messages for sent/received messages now always include the following info: * peer id of sender * peer id of receiver * message key * message type There was already logging for the individual handlers but it was inconsistent (for example some log the peer id of self while others do not) and did not provide full information in all cases (some handlers do not log the key)
a2c7c3c
to
ea2eedb
Compare
@@ -70,6 +71,9 @@ func (dht *IpfsDHT) handleNewMessage(s inet.Stream) { | |||
return | |||
} | |||
|
|||
// log the received message | |||
log.Event(ctx, "handleNewMessage", mPeer, pmes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be a span event, like the others. That is, use log.Start
and log.Finish
. Really, we may want to break the rest of this function out into a separate function (so we can use defer to end the event).
@@ -108,41 +112,60 @@ func (dht *IpfsDHT) handleNewMessage(s inet.Stream) { | |||
} | |||
} | |||
|
|||
func tagWithMessage(ctx context.Context, name string, msg *pb.Message) { | |||
log.SetTag(ctx, name+".key", b58.Encode([]byte(msg.GetKey()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be a bit expensive. Let's wait for #200, then we can use the loggableKey
helper type to format lazily and on-demand.
return nil, err | ||
} | ||
tagWithMessage(ctx, "response", rpmes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the benefit of tagging the response and request differently. The key and type should be identical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for this is the request/response are part of the same span, so if we tag them the same, one will overwrite the other. We could convert this to span events, but that'll be ugly as well since span events only support single k/v (no nesting) AFAIK.
The log messages for sent/received messages now always include the following info:
There was already logging for the individual handlers but it was
inconsistent (for example some log the peer id of self while others do not) and
did not provide full information in all cases (some handlers do not log the key)