Repository navigation
feat: count the messages and the bytes in and out of the peer, for each command, in four counters of the metrics (#79) - #96
Open
lorenzolfm wants to merge 3 commits into
Open
lorenzolfm wants to merge 3 commits into
lorenzolfm wants to merge 3 commits into
Conversation
…ch command, in four counters of the metrics (#79) The socket of a connection has the metrics, so each message is counted at the one place where elo reads it and the one place where elo writes it. A received message counts when elo has its full frame and the frame is valid. A sent message counts when its write ends. The bytes include the 24 bytes of the header, as in the per-message bytes of the peer. The label `command` has a fixed set of values: each command that elo knows, and `other` for each other command. So a peer cannot add series. The sent and the received counters have the same values, so that one query can match the two directions. Some sent series stay at 0. The counters do not reset at a reconnect, as a counter must not go down. The longest body is now 4993 bytes, so `BODY_LENGTH_MAX` is 8 KiB.
…shake is a reconnect too, and that Prometheus rounds the work (#79)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #79.
What
command:elo_peer_received_messages_total,elo_peer_received_bytes_total,elo_peer_sent_messages_total,elo_peer_sent_bytes_total.Socketholds&Metrics. Sonet::handshaketakes&Metrics, andmain.rsgives it.BODY_LENGTH_MAXgoes from 2 KiB to 8 KiB.--metrics, serve the tip, the step of the peer and the reconnects atGET /metrics, in the Prometheus text format (#79) #95:elo_reconnects_totaland the float64 rounding ofelo_header_tip_work.Why
Count in
Socket. Each message that elo reads goes throughSocket::receive. Each message that elo writes goes throughSocket::send. So two calls count all of the messages, of the handshake and after it. Rejected: count inrun_sendandrun_turn. That needs more calls, and the handshake has its own path.When a message counts. A received message counts when elo has its full frame and the checksum is correct. A frame with a bad checksum ends the connection, and does not count. A sent message counts when
write_allends. A write that a send timeout stops does not count.Bytes include the 24-byte header. The per-message bytes of Core's
getpeerinfoinclude the header too. So the two can be compared.Metricsadds the header, sonet.rshas no arithmetic, and the unit tests kill each mutant of it.A fixed set of
commandvalues. The values are the 10 commands inprotocol.rs, andotherfor each other command. A peer cannot add a series with a new command name. The tableCOMMANDShas the message type and the label of each command. A test checks that each label is the name of its message type.The same values in the two directions. Sent and received have all 11 values, so one query can match the two directions. elo does not send
headers,inv,wtxidrelay,sendaddrv2orother, so these 5 sent series stay at 0. Rejected: a second set for the sent commands. It needs one more type, and a new command (#62getdata) would go into two lists.No reset at a reconnect. A counter must not go down. Prometheus
rate()sees a reset as a restart.8 KiB. With each value at its maximum, the body is now at most 4993 bytes (the assert in
Text::endgives this number). 4 KiB is too small. So 8 KiB, the next power of 2, as for the 2 KiB in #95. That leaves about 3 KiB for the metrics of #62 and #64.Doc nits.
elo_reconnects_totalcounts each move intowait: also a failed lookup, dial or handshake, not only a connection that ended. The help and the README now say so. The README says that Prometheus keeps a 64-bit float, so it rounds a work above 2^53.Checks
metrics_of_elo_have_its_tip_its_step_each_reconnect_and_the_bytes_of_each_command: after a sync of 2001 headers, the bytes of eachcommandare equal to the per-message bytes ofgetpeerinfo, in the two directions. Core sendssendcmpctandfeefilter, and these go intoother(2 messages, 65 bytes).promtool check metrics(Prometheus 3.16) accepts a real scrape (3985 bytes).nix flake checkpasses. L3 ran in a netns.Not confident
otherhides which unknown command a peer sends. The log does not show it either. If that is necessary, more commands can go intoCOMMANDS.net.rschecks the counts.Metricshas no read function for other modules, and I did not add one for a test. The L3 test checks the two calls against Core.