-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Add inbound connections metrics #49103
Conversation
Pinging @elastic/es-distributed (:Distributed/Network) |
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.
Can you add a REST test as well? That makes it easier to see what new metrics have been added. No need to assert on the field values, just assert that all relevant fields are present.
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.
Some questions/comments.
void inboundMessage(TcpChannel channel, BytesReference message) throws Exception { | ||
channel.getChannelStats().markAccessed(threadPool.relativeTimeInMillis()); | ||
TransportLogger.logInboundMessage(channel, message); | ||
readBytesMetric.inc(message.length() + TcpHeader.MARKER_BYTES_SIZE + TcpHeader.MESSAGE_LENGTH_SIZE); | ||
readBytesMetric.inc(getMessageSizeWithHeader(message)); |
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.
Just store this in a variable so you can reuse it in the other two places below :)
static final String RESPONSES_SENT_SIZE_IN_BYTES = "resp_sent_size_in_bytes"; | ||
static final String KEEP_ALIVE_PINGS_RECEIVED_COUNT = "keep_alive_pings_rcv_count"; | ||
static final String KEEP_ALIVE_PINGS_RECEIVED_SIZE = "keep_alive_pings_rcv_size"; | ||
static final String KEEP_ALIVE_PINGS_RECEIVED_SIZE_IN_BYTES = "keep_alive_pings_rcv_size_in_bytes"; |
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.
Exposing (and generally separately tracking) the size of pings and pongs seems somewhat redundant since we can compute them from counts?
In particular, this would resolve the issue of getting inconsistent data in these stats (since the number of bytes and the count can change between calls to count
and sum
).
MeanMetric outboundResponses = outboundHandler.getOutboundResponses(); | ||
MeanMetric inboundKeepAlivePings = inboundHandler.getInboundKeepAlivePings(); | ||
MeanMetric outboundKeepAlivePongs = outboundHandler.getOutboundKeepAlivePongs(); | ||
TransportStats.InboundConnectionsStats inboundConnectionsStats = new TransportStats.InboundConnectionsStats( |
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.
Maybe create a Builder
for TransportStats.InboundConnectionsStats
. This constructor already pretty much impossible to read without an IDE showing parameter names and it's just going to get worse as we add more to this object?
} else { | ||
bytesMetric = outboundPingsMetric; | ||
} | ||
SendContext sendContext = new SendContext(channel, bytesMetric, () -> serializedPing, listener); |
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 can just be deduplicated by adding a metric
parameter to sendBytes
and reusing it here. Though (see my other comment on this) we probably don't need to even track the bytes in pings and pongs separate from other bytes.
inboundOpenedChannels.inc(); | ||
channel.addCloseListener(ActionListener.wrap(() -> { | ||
acceptedChannels.remove(channel); | ||
inboundClosedChannels.inc(); |
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.
One of the two metrics here is redundant since openedChannels - closedChannels = acceptedChannels.size()
. I think it's more useful to expose the number of currently open channels and either the open or close count instead of keeping track of a redundant counter here, both implementation wise and in terms of usefulness for the consumer of these numbers. That's also what is suggested in the meta #36127 I think
private final long keepAlivePongsSentCount; | ||
private final long keepAlivePongsSentBytes; | ||
|
||
static final String INBOUND_CONNECTIONS = "inbound_connections"; |
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.
As suggested in the other comment and #36127, probably better to make this a gauge and only keep the closed counter.
This commit adds the following metrics for inbound connections:
There is no separate reporting for each interface so far (anyway currently only single publish address is supported).