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

Record Jetty bytes in/out metrics through network listeners #4514

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

marcingrzejszczak
Copy link
Contributor

before this change we were dumping in / out bytes from the connection upon the connection close which could result in big traffic whenever the connection got closed after this change we're measuring the bytes through NetworkTrafficListener that hooks in whenever actual in / out bytes are being processed

fixes gh-3873

before this change we were dumping in / out bytes from the connection upon the connection close which could result in big traffic whenever the connection got closed
after this change we're measuring the bytes through NetworkTrafficListener that hooks in whenever actual in / out bytes are being processed

fixes gh-3873
Copy link
Member

@shakuzen shakuzen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the difference in the number of bytes counted. It would be good to understand that. The description of the metrics should be updated as well.

connector.addBean(new JettyConnectionMetrics(registry));
JettyConnectionMetrics metrics = new JettyConnectionMetrics(registry);
connector.addBean(metrics);
connector.addNetworkTrafficListener(metrics);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like new setup that isn't documented in the class JavaDoc or done in the static addToAllConnectors method. It will be a behavior change that the bytes in/out will only be available if this is set, right?

Copy link
Contributor Author

@marcingrzejszczak marcingrzejszczak Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct plus I'm also showing this in the tests that bytes are not equal to what they were used to. So not only do you need to set it up differently but also the result is different

@shakuzen
Copy link
Member

shakuzen commented Mar 5, 2024

@joakime do you have some time to help us understand this? When changing from counting the bytes in/out on the connection to a network listener and we're getting different numbers.

@joakime
Copy link
Contributor

joakime commented Mar 5, 2024

Depending on where the integration point is in the handler tree you will either see the bytes as initiated by the webapp, or the bytes as sent on the network.

The most obvious and largest difference would be if a GzipHandler is in place.
You could be getting the bytes as seen before the compression or after the compression.

The techniques that micrometer were using in Jetty 9/10/11 were only seeing the bytes passing through the HttpOutput / HttpInput classes.
Which is not network bytes.

Using the org.eclipse.jetty.io.NetworkTrafficListener you will get everything on the network.

  • The Headers
  • The Body
  • The Transfer-Encoding differences (like chunking overhead)
  • The HTTP Trailers
  • The TLS negotiation
  • The TLS overhead
  • The HTTP protocol overhead (like in HTTP/2)

While in the techniques you used in Jetty 9/10/11 on micrometer you saw only the Body before Transfer-Encoding.

@shakuzen shakuzen changed the title Starts recording Jetty metrics through network listeners Record Jetty bytes in/out metrics through network listeners Mar 6, 2024
@shakuzen shakuzen added enhancement A general enhancement module: micrometer-core An issue that is related to our core module instrumentation An issue that is related to instrumenting a component labels Mar 6, 2024
@shakuzen shakuzen added this to the 1.13.0-M2 milestone Mar 6, 2024
@shakuzen
Copy link
Member

shakuzen commented Mar 6, 2024

Thanks for the explanation. One effect of changing from counting the bytes via Connection.Listener to NetworkTrafficListener seems to be the loss of the ability to count the bytes in/out for HttpClient, because there's no way to register a NetworkTrafficListener on an HttpClient as far as I can tell; it can only be registered on the server-side. Is that right?

@joakime
Copy link
Contributor

joakime commented Mar 6, 2024

I agree, it would be nice to have HttpClient also participate in NetworkTrafficListener ...

So I opened jetty/jetty.project#11491 to do just that!

@shakuzen
Copy link
Member

shakuzen commented Mar 7, 2024

Thank you for that. I've subscribed to the issue. We can update our tests/documentation when that is available.

@shakuzen shakuzen modified the milestones: 1.13.0-M2, 1.13.0-RC1 Mar 11, 2024
@shakuzen shakuzen merged commit 0fce7ef into main Apr 8, 2024
7 checks passed
@shakuzen shakuzen deleted the issues_#3873 branch April 8, 2024 16:56
shakuzen added a commit that referenced this pull request May 13, 2024
The configuration necessary for getting all the Jetty connection metrics changed with gh-4514. This updates the corresponding documentation to include this.

Closes gh-4981
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A general enhancement instrumentation An issue that is related to instrumenting a component module: micrometer-core An issue that is related to our core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jetty Connector Metrics are only reported onClosed
3 participants