Created attachment 36534 [details] Screenshot from JConsole & Chrome Dev Tools Websocket communication in web app is not counted to statistics of bytes sent and received - obtainable via MBean: e.g. Catalina:type=GlobalRequestProcessor,name="http-nio-8080", containing attributes bytesReceived, bytesSent. Please see attachment for details.
Yes, this only tracks non upgraded HTTP/1.1 activity at this time.
What is the request here? Are new statistics required? Are changes to how the existing statistics are calculated required? Specifics would help us to evaluate the request. The current statistics were implemented when Tomcat only implemented HTTP/1.1 (and 1.0 and 0.9). Now Tomcat supports WebSocket, HTTP/2 and generic HTTP/1/ upgrade. Do stats need to be broken down by protocol? Is the 'right' solution something that needs to wait for major refactoring in Tomcat 10? (Or is there something useful we can do now for 9.0.x?)
I guess it would have to be counted in the SocketWrapper, but is that kind of metric useful at all these days ? We know/expect it will be some random large amount, and that's all it will say. At the same time, it's slightly annoying to collect. Access logging should give a much better idea on what's going on. Personally, I'd rather leave it the way it is now and remove it in Tomcat.next.
Our code has implementation of feeding metrics with sent/received number of bytes from web server. Generally the metrics is important to check amount of data transferred from/to web application in elegant way - that means we do not need implement counting by ourselves for every API endpoint in our app (HTTP or Websocket). We had migrated our app from Wildfly, which counts Websocket + HTTP communication together correctly, but I understand that this is not feature crucial to be present there. So we are ok also with decision, that the counting will be implemented by ourselves - albeit take the numbers collected by Tomcat is the easier option ;)
Note: HTTP/2 traffic is also excluded from the GlobalRequestProcessor metrics.
Working on this. On HTTP/2 at the moment.
Fixed for HTTP/2 in: - 10.0.x for 10.0.0-M10 onwards - 9.0.x for 9.0.40 onwards - 8.5.x for 8.5.60 onwards Still thinking about how to tackle WebSocket.
Support added for WebSocket and generic HTTP upgrade protocols. Fixed in: - 10.0.x for 10.0.0-M10 onwards - 9.0.x for 9.0.40 onwards - 8.5.x for 8.5.60 onwards