-
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
base: main
Are you sure you want to change the base?
Changes from all commits
0beccc8
24bc1f7
d3f8740
0bf2e08
7506635
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * Copyright 2025 LINE Corporation | ||
| * | ||
| * LINE Corporation licenses this file to you under the Apache License, | ||
| * version 2.0 (the "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at: | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| * License for the specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package com.linecorp.armeria.common; | ||
divijvaidya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import com.linecorp.armeria.common.metric.MoreMeters; | ||
| import com.linecorp.armeria.common.util.EventLoopGroups; | ||
|
|
||
| import io.micrometer.core.instrument.binder.netty4.NettyMeters; | ||
| 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 { | ||
| CommonPools.bindEventLoopMetricsForWorkerGroup(testGroup); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that 1) What do you think of adding a second parameter |
||
|
|
||
| // verify that registry contains the newly added metrics | ||
| final Map<String, Double> registeredMeters = MoreMeters.measureAll(Flags.meterRegistry()); | ||
| assertThat(registeredMeters.keySet() | ||
| .stream() | ||
| .anyMatch(key -> key.startsWith( | ||
| NettyMeters.EVENT_EXECUTOR_TASKS_PENDING.getName()))) | ||
| .isTrue(); | ||
| } finally { | ||
| testGroup.shutdownNow(); | ||
| } | ||
| } | ||
| } | ||
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.