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

feat: add handshake protocol messages metrics #2490

Merged
merged 1 commit into from
Sep 14, 2021
Merged

Conversation

mrekucci
Copy link
Contributor

@mrekucci mrekucci commented Sep 9, 2021

This change is Reviewable

@mrekucci mrekucci added the ready for review The PR is ready to be reviewed label Sep 9, 2021
@mrekucci mrekucci requested review from acud and notanatol and removed request for acud September 9, 2021 15:47
@mrekucci mrekucci mentioned this pull request Sep 9, 2021
@mrekucci mrekucci requested a review from acud September 9, 2021 16:14
@mrekucci mrekucci requested a review from acud September 13, 2021 08:31
Copy link
Contributor Author

@mrekucci mrekucci left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @acud and @notanatol)


pkg/p2p/libp2p/internal/handshake/handshake.go, line 115 at r1 (raw file):

Previously, acud (acud) wrote…

exposing metrics from this package might be tricky... since the package is internal and metrics need to be registered inside the node.go file

Nice catch! Since the handshake is an internal part of the libp2p, I'll instantiate it as a part of the libp2p Matrics() call.

@mrekucci mrekucci force-pushed the handshake-metrics branch 2 times, most recently from e94a329 to a92bb46 Compare September 13, 2021 13:42
Copy link
Member

@acud acud left a comment

Choose a reason for hiding this comment

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

I would suggest to split this into two: (1) metrics only PR (2) adding logging for specific debugging sessions which should not end up on master (and don't need a PR per-se)

Reviewed 2 of 2 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @mrekucci and @notanatol)


pkg/p2p/libp2p/internal/handshake/handshake.go, line 253 at r2 (raw file):

	if err := r.ReadMsgWithContext(ctx, &syn); err != nil {
		s.metrics.SynRxFailed.Inc()
		s.logger.Tracef("handshake: read syn msg error; took: %s", time.Since(beginning))

you are logging and returning an error, which is not needed since the error would normally be logged anyway by the calling context. if timing info is needed you can instrument the error with it in the line below


pkg/p2p/libp2p/internal/handshake/handshake.go, line 257 at r2 (raw file):

	}
	s.metrics.SynRx.Inc()
	s.logger.Tracef("handshake: read syn msg took: %s", time.Since(beginning))

perhaps this can be added to an already existing logline, so we don't clutter the terminal with too much information? if specific debugging information is needed in order to find a bug this is fine, but then maybe we don't need to have it on master


pkg/p2p/libp2p/internal/handshake/handshake.go, line 299 at r2 (raw file):

	}); err != nil {
		s.metrics.SynAckTxFailed.Inc()
		s.logger.Tracef("handshake: write syn ack msg error; took: %s; total: %s", time.Since(start), time.Since(beginning))

same comment here about logging and returning an error. it is fine if it doesn't end up on master though)

@mrekucci mrekucci requested a review from acud September 14, 2021 08:29
Copy link
Contributor Author

@mrekucci mrekucci left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @acud, @mrekucci, and @notanatol)


pkg/p2p/libp2p/internal/handshake/handshake.go, line 253 at r2 (raw file):

you are logging and returning an error

The trace logging is about knowing how much of time each step took in the protocol execution not about logging an error.

if timing info is needed you can instrument the error with it in the line below

It can be inferred but not with such granularity or when the step is successful.

I agree though that I can move the traces into a separate branch.

@mrekucci mrekucci force-pushed the handshake-metrics branch 2 times, most recently from 7508dc4 to d5740eb Compare September 14, 2021 14:34
@acud acud force-pushed the handshake-metrics branch 2 times, most recently from 96ac391 to c8e2efe Compare September 14, 2021 16:47
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mrekucci mrekucci merged commit fe04e10 into master Sep 14, 2021
@mrekucci mrekucci deleted the handshake-metrics branch September 14, 2021 18:07
@acud acud added this to the v1.2.0 milestone Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull-request ready for review The PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants