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

Add inbound connections metrics #49103

Closed
wants to merge 1 commit into from

Conversation

andrershov
Copy link
Contributor

@andrershov andrershov commented Nov 14, 2019

This commit adds the following metrics for inbound connections:

  • Opened channels
  • Closed channels
  • Inbound request count / size
  • Outbound responses count / size
  • Inbound keep alive pings count / size
  • Outbound keep alive pongs count / size

There is no separate reporting for each interface so far (anyway currently only single publish address is supported).

@andrershov andrershov added >feature :Distributed Coordination/Network Http and internode communication implementations v8.0.0 labels Nov 14, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (:Distributed/Network)

@andrershov andrershov changed the title [WIP] Add inbound connections metrics Add inbound connections metrics Nov 14, 2019
Copy link
Contributor

@ywelsch ywelsch left a 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.

Copy link
Member

@original-brownbear original-brownbear left a 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));
Copy link
Member

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";
Copy link
Member

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(
Copy link
Member

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);
Copy link
Member

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();
Copy link
Member

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";
Copy link
Member

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.

@rjernst rjernst added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label May 4, 2020
@Tim-Brooks Tim-Brooks closed this Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Network Http and internode communication implementations >feature Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v8.0.0-alpha2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants