jetty.project
jetty.project copied to clipboard
Improve ConnectionStatistics to report per-protocol information
Currently, ConnectionStatistics listens to the "connection closed" event, and when it happens it retrieves the connection information from the Connection object passed in the event.
Would be great if this information could be split per-protocol.
This would involve:
- a new
Connection.getProtocol()method so that it would be possible to know what protocol was that connection speaking - a different implementation of
ConnectionStatisticsto store per-protocol information (as well as the totals) - Possibly a
ConnectionStatisticsMBeanthat displays the per-protocol data in a JMX friendly way. JMX'sCompositeTyperepresents a struct; in this case it can have these fields:[protocol, bytesIn, bytesOut, messagesIn, messagesOut]. JMX'sCompositeDatais an instance of the struct with the actual values for those fields. JMX'sTabularDatais aMapwhere you can map aStringto aCompositeData(I think - this class is so obscure I completely forgotten it was so obscure). Point being that either via an array ofCompositeData, or viaTabularDatawe can return the connection information split by protocol.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
@sbordet we now have IncludeExcludeConnectionStatistics which can can only record stats for specific types of connection. This can be used to get stats for a specific protocol, for the websocket protocol we get stats by including org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.
However this would be a much cleaner solution to have all the information in ConnectionStatistics instead of having multiple IncludeExcludeConnectionStatistics for different protocols.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hello, Is this issue still valid?
@arsenalzp yes, it is still valid.
I take it, if it's possible!
Please do.
I've just found per-protocol ConnectionStatistics reports have already been implemented:
public void onClosed(Connection connection)
{
if (!isStarted())
return;
onTotalClosed(connection);
onConnectionClosed(connection);
}
However, protocol name is taken from class name of the connection instance:
protected void onConnectionClosed(Connection connection)
{
Stats stats = _statsMap.get(connection.getClass().getName());
if (stats != null)
onClosed(stats, connection);
}
So, I propose:
-
add
Connection.getProtocol()method to get protocol name, for example forHttpConnectionit isgetHttpVersion().asString(); -
look at all connection implementations to check was
getProtocolmethod implemented and correct information is returned; -
rewrite
ConnectionStatisticsto useConnection.getProtocol()instead ofConnection.getClass().getName(); -
try to implement
ConnectionStatisticsMBeanfor JMX.
@arsenalzp I forgot that this was done already 🤦🏼♂️
I think we can just close this issue.
I don't see much value adding Connection.getProtocol().
However, the ConnectionStatisticsMBean can definitely be improved.
@arsenalzp would you like to look at improving ConnectionStatisticsMBean by using JMX open types?
See the first comment: ConnectionStatistics.Stats should be converted to a TabularData.
As usual, comment here for directions/help, and I'll help you out.
Thanks!
@arsenalzp I forgot that this was done already 🤦🏼♂️
I think we can just close this issue.
I don't see much value adding
Connection.getProtocol().However, the
ConnectionStatisticsMBeancan definitely be improved. @arsenalzp would you like to look at improvingConnectionStatisticsMBeanby using JMX open types? See the first comment:ConnectionStatistics.Statsshould be converted to aTabularData. As usual, comment here for directions/help, and I'll help you out. Thanks!
Yes, I cat try to improve it!