-
Notifications
You must be signed in to change notification settings - Fork 921
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 barebones Netty event-loop metrics #4750
Conversation
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.
👋 Thanks for your first contribution, @vkostyukov!
core/src/main/java/com/linecorp/armeria/internal/common/metric/NettyMetricSupport.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/HttpClientFactory.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/internal/common/metric/NettyMetricsSupportTest.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/common/metric/NettyMetricSupport.java
Outdated
Show resolved
Hide resolved
e377ccf
to
b25f638
Compare
core/src/main/java/com/linecorp/armeria/internal/common/metric/NettyMetricSupport.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/common/metric/NettyMetricSupport.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/common/metric/NettyMetricSupport.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/common/metric/NettyMetricSupport.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/common/metric/NettyMetricSupport.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/common/metric/NettyMetricSupport.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/internal/common/metric/NettyMetricsSupportTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/internal/common/metric/NettyMetricsSupportTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/internal/common/metric/NettyMetricsSupportTest.java
Outdated
Show resolved
Hide resolved
af936c2
to
3db0fc1
Compare
3db0fc1
to
59624c3
Compare
@ikhoon mind taking another look when you get a chance? Ty! |
4ebf151
to
9cca856
Compare
@ikhoon linter should be happy now. Not super sure about other failures - they seemed unrelated. I'm happy to dig more if you think otherwise. |
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.
I believe we are on the same page. Left comments on code style and visibility.
core/src/main/java/com/linecorp/armeria/common/metric/MoreMetrics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/metric/NettyMetrics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/metric/NettyMetrics.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/common/metric/NettyMetricsTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/common/metric/NettyMetricsTest.java
Outdated
Show resolved
Hide resolved
9cca856
to
ce03bc1
Compare
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.
Thanks a lot for the solid work, @vkostyukov. Left some minor comments. 🙇
core/src/main/java/com/linecorp/armeria/common/CommonPools.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/metric/EventLoopMetrics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/metric/EventLoopMetrics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/metric/EventLoopMetrics.java
Outdated
Show resolved
Hide resolved
* - "event.loops.pending.tasks" (gauge) - the total number of IO tasks waiting to be run on event loops* | ||
* </p> | ||
*/ | ||
public static MeterBinder eventLoopMetrics(MeterIdPrefix idPrefix, EventLoopGroup eventLoopGroup) { |
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.
What do you think about merging this class into MoreMeters
?
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 would be the first method there returning MeterBinder (or metrics in that sense).
MoreMeters seems to mostly contain utilities to work with MeterRegistry
, which is also suggested by its javadoc:
// Provides utilities for accessing MeterRegistry.
I'd probably vote for keeping MoreMetrics
as a factory for creating MeterBinders.
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.
IMHO, it's better to merge those classes because it can be a bit distracting for users to find Micrometer relates utilities. We can fix the Javadoc of MoreMeters
if that's the problem. 😄
Anyway, we still need to add @UnstableApi
because this is a newly-added public method. 😉
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.
Added @UnstableApi
annotation for eventLoopMetrics
.
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.
Thanks, @vkostyukov! ❤️
LGTM if @trustin comments are addressed.
ce03bc1
to
238fe6f
Compare
@trustin Just updated. PTAL once you have a chance. |
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.
Left only style suggestions. Thanks! 😄
core/src/main/java/com/linecorp/armeria/common/metric/EventLoopMetrics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/metric/EventLoopMetrics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/metric/EventLoopMetrics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/metric/EventLoopMetrics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/metric/EventLoopMetrics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/metric/MoreMetrics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/metric/MoreMetrics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/metric/EventLoopMetrics.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/common/metric/EventLoopMetricsTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/common/metric/EventLoopMetricsTest.java
Outdated
Show resolved
Hide resolved
238fe6f
to
23ac366
Compare
Thanks for looking. Just pushed an update. PTAL again |
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.
Great! Thanks a lot for adding these nice metrics! 😄
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.
Left a minor #4750 (comment) but looks good to me! Thanks a lot @vkostyukov ! 🙇 👍 🚀
core/src/main/java/com/linecorp/armeria/common/metric/EventLoopMetrics.java
Show resolved
Hide resolved
parent.gauge(pendingTasks, idPrefix.tags(), this, Self::pendingTasks); | ||
} | ||
|
||
// This runs every 3 seconds at most. |
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.
Note: I wondered for a second whether it's worth caching these stats since:
- The computing logic doesn't seem too expensive and most likely will run on a separate thread
- The collector implementation has more transparency on when metrics are computed
- The current implementation doesn't guarantee stats are cached for concurrent requests anyways
Having said this, I think the current implementation is fine 👍
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.
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.
That's a good point. @jrhee17 👍
I thought caching is okay because this type of information does not need to be immediately reflected in actual values.
Of course, we can revisit this later if we need to fix it. 😄
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.
I'd down to simplify it. I think pendingTask is pretty cheap to run. Let me make the change.
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.
Updated! PTAL
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.
Still LGTM. Thanks!
23ac366
to
7600fd8
Compare
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.
Thanks @vkostyukov ! Looks really nice 🚀 👍 🙇
7600fd8
to
f4a84ec
Compare
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.
Thanks a lot, @vkostyukov!
Let me make the following changes and merge:
|
* exported per registered {@link MeterIdPrefix}. | ||
* | ||
* <ul> | ||
* <li>"event.loop.num.workers" (gauge) - the total number of Netty's event loops</li> |
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.
Note: Let me remove num
in the release note.
Motivation:
We want to export some very basic metrics about the underlying Netty runtime. Let's start with the number of event-loops and the number of IO tasks waiting to be executed.
Modifications:
EventLoopMetrics
, which implementsMeterBinder
.CommonPools
event-loop-groups for metrics collection.Result:
EventLoop
#4675