-
Notifications
You must be signed in to change notification settings - Fork 896
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 ServerMetrics to collect metrics related server #5627
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.
Looks great, @seongbeenkim! Left some suggestions. 😉
core/src/test/java/com/linecorp/armeria/server/ServerMetricsTest.java
Outdated
Show resolved
Hide resolved
@@ -574,14 +575,19 @@ private ChannelFuture doStart(ServerPort port) { | |||
} | |||
|
|||
private void setupServerMetrics() { | |||
final MeterRegistry meterRegistry = config().meterRegistry(); | |||
final MeterRegistry meterRegistry = config.meterRegistry(); | |||
final ServerMetrics serverMetrics = config.serverMetrics(); | |||
final GracefulShutdownSupport gracefulShutdownSupport = this.gracefulShutdownSupport; | |||
assert gracefulShutdownSupport != null; | |||
|
|||
meterRegistry.gauge("armeria.server.pending.responses", gracefulShutdownSupport, | |||
GracefulShutdownSupport::pendingResponses); |
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.
@seongbeenkim is going to add the metric to the ServerMetrics
in the follow-up PR.
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.
Question) Could "armeria.server.pending.responses"
be deprecated?
I guess ServerMetric. activeRequests()
== GracefulShutdownSupport.pendingResponses()
.
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.
pendingResponses
does not include the transient service requests, meanwhile activeRequests
include them.
If we make activeRequests
do not contain the transient service requests, we can deprecate pendingResponses
. But I wasn't sure if it was okay. 🤔
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.
It is hard to notice from the metric name that the difference between the two metrics is the existence of transient services.
We may add an API and a new tag to explicitly expose the number of transient service requests in the f/u work.
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.
Yeah, that's a good suggestion. 👍
core/src/main/java/com/linecorp/armeria/server/HttpServerHandler.java
Outdated
Show resolved
Hide resolved
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.
Looks good overall! Left some minor comments
core/src/test/java/com/linecorp/armeria/server/ConnectionLimitingHandlerTest.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/ServerMetrics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/AbstractHttpResponseHandler.java
Outdated
Show resolved
Hide resolved
Let me resolve the conflict. 😉 |
Gentle ping 🙏 |
I've pushed commits because we are about to release the next version. |
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.
@seongbeenkim Thanks for the all your work! 😄
core/src/main/java/com/linecorp/armeria/server/ServerMetrics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/ServerMetrics.java
Outdated
Show resolved
Hide resolved
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.
It looks like a useful feature. ServerMetric
may be used to implement a graceful shutdown logic.
Thanks, @seongbeenkim and @minwoox.
@@ -574,14 +575,19 @@ private ChannelFuture doStart(ServerPort port) { | |||
} | |||
|
|||
private void setupServerMetrics() { | |||
final MeterRegistry meterRegistry = config().meterRegistry(); | |||
final MeterRegistry meterRegistry = config.meterRegistry(); | |||
final ServerMetrics serverMetrics = config.serverMetrics(); | |||
final GracefulShutdownSupport gracefulShutdownSupport = this.gracefulShutdownSupport; | |||
assert gracefulShutdownSupport != null; | |||
|
|||
meterRegistry.gauge("armeria.server.pending.responses", gracefulShutdownSupport, | |||
GracefulShutdownSupport::pendingResponses); |
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.
Question) Could "armeria.server.pending.responses"
be deprecated?
I guess ServerMetric. activeRequests()
== GracefulShutdownSupport.pendingResponses()
.
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.
Looks good overall 👍 Pushed a small commit which cleans up dead code and tests.
Also left a comment which I'm not how to handle at the moment 🤔
core/src/main/java/com/linecorp/armeria/server/EmptyContentDecodedHttpRequest.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/Http1RequestDecoder.java
Outdated
Show resolved
Hide resolved
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.
Thank very much, @seongbeenkim and @minwoox! 🙇
System.nanoTime(), SystemInfo.currentTimeMicros(), true, false | ||
); |
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.
Perhaps we can revert this cosmetic change?
System.nanoTime(), SystemInfo.currentTimeMicros(), true, false | |
); | |
System.nanoTime(), SystemInfo.currentTimeMicros(), true, false); |
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 addressed. 😉
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, @seongbeenkim! 😉 |
Motivation:
Add
ServerMetrics
to collect metrics related server. #4992Modifications:
ServerMetrics.increasePendingHttp1Requests()
in
Http1RequestDecoder#channelRead
beforefireChannelRead()
ServerMetrics.increasePendingHttp2Requests()
in
Http2RequestDecoder#onHeadersRead
beforefireChannelRead()
ServerMetrics.decreasePendingHttp1Requests()
,ServerMetrics.decreasePendingHttp2Requests()
,ServerMetrics.increaseActiveHttp1WebSocketRequests()
,ServerMetrics.increaseActiveHttp1Requests()
andServerMetrics.increaseActiveHttp2Requests()
in
HttpServerHandler#serve0
beforeservice.serve(reqCtx, req)
ServerMetrics.decreaseActiveHttp1WebSocketRequests()
,ServerMetrics.decreaseActiveHttp1Requests()
andServerMetrics.decreaseActiveHttp2Requests()
in
AbstractHttpResponseHandler#tryComplete
ServerMetrics.increaseActiveConnectionsAndGet()
andServerMetrics.decreaseActiveConnections()
in
ConnectionLimitingHandler#channelRead
Result: