-
Notifications
You must be signed in to change notification settings - Fork 973
Emit Netty event loop metrics provided by MicroMeter #6290
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
Open
divijvaidya
wants to merge
5
commits into
line:main
Choose a base branch
from
divijvaidya:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0beccc8
Emit event loop metrics provided by MicroMeter
divijvaidya 24bc1f7
Simpify test and remove dependency on mockito inline
divijvaidya d3f8740
add new guideline for header
divijvaidya 0bf2e08
Revert "add new guideline for header"
divijvaidya 7506635
Merge branch 'line:main' into main
divijvaidya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
core/src/test/java/com/linecorp/armeria/common/CommonPoolsTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package com.linecorp.armeria.common; | ||
divijvaidya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.Mockito.verify; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.mockito.MockedConstruction; | ||
| import org.mockito.Mockito; | ||
|
|
||
| import com.linecorp.armeria.common.util.EventLoopGroups; | ||
|
|
||
| import io.micrometer.core.instrument.binder.netty4.NettyEventExecutorMetrics; | ||
| import io.netty.channel.EventLoopGroup; | ||
|
|
||
| public class CommonPoolsTest { | ||
| @Test | ||
| public void testEventLoopMetricsBinding() throws Exception { | ||
divijvaidya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| final EventLoopGroup testGroup = EventLoopGroups.newEventLoopGroup(1); | ||
|
|
||
| try { | ||
| try (MockedConstruction<NettyEventExecutorMetrics> microMeterEventloopMetrics = | ||
| Mockito.mockConstruction(NettyEventExecutorMetrics.class)) { | ||
| CommonPools.bindEventLoopMetricsForWorkerGroup(testGroup); | ||
|
|
||
| assertThat(microMeterEventloopMetrics.constructed().isEmpty()).isFalse(); | ||
|
|
||
| final NettyEventExecutorMetrics instance = microMeterEventloopMetrics.constructed().get(0); | ||
| verify(instance).bindTo(any()); | ||
| } | ||
| } finally { | ||
| testGroup.shutdownNow(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Let's add
@Deprecatedto the class. 😉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.
Woud you also deprecate
MoreMeterBinders.eventLoopMetrics()that takesnameandmeterIdPrefix?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 did not deprecate the whole class because it emits a metric (num event loop workers) which is not available in Micrometer right now. We will continue using it until we are able to add that metric in Micrometer.
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 of first adding the metric to
Micrometerfirst before proceeding with this PR?I think the direction of this PR will be clearer if we can consider
NettyEventExecutorMetricsas a replacement ofMoreMeterBinders.eventLoopMetrics.Also, it would be nice if the meter name prefix can also be specified like
ExecutorServiceMetricsdoes - especially given that thread names are not necessarily unique. It can also allow users to grouparmeriarelated metrics easily depending on the prefix.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 agree with you. Initially, I thought users could simply count the number of event loops using a count query with the name tag,
but since there's some additional calculation involved, we probably do need to add the metric as well.
I thought the current approach was fine because I personally recommend using only a single event loop group.
However, there are cases where users can't unify event loop groups — for example, when using Armeria with Lettuce.
So, let's ask the Micrometer team if it's possible to customize the meter name
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.
ok, I will get that done.