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

Add pendingResponse to ServerMetrics #5895

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

EunJungYoo
Copy link

Motivation:

  • Related Issue: Add pendingResponses to ServerMetrics #5666
  • Currently, GracefulShutdownSupport manages the pendingResponse metric. With the introduction of the ServerMetrics class, which handles server-related metrics, it’s necessary to consolidate the management of pendingResponse within ServerMetrics for better organization and consistency.

Modifications:

  • Moved the pendingResponse metric from GracefulShutdownSupport to ServerMetrics.
  • Renamed the pendingResponses method to activeNonTransientResponses to better reflect its purpose and functionality.

Result:

@CLAassistant
Copy link

CLAassistant commented Sep 7, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

codecov bot commented Sep 7, 2024

Codecov Report

Attention: Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.66%. Comparing base (9a29b39) to head (736963a).
Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
...ava/com/linecorp/armeria/server/ServerMetrics.java 88.88% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5895      +/-   ##
============================================
- Coverage     74.66%   74.66%   -0.01%     
- Complexity    21681    21704      +23     
============================================
  Files          1896     1897       +1     
  Lines         80320    80391      +71     
  Branches      10548    10553       +5     
============================================
+ Hits          59974    60023      +49     
- Misses        15318    15339      +21     
- Partials       5028     5029       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

Only left nit comments, basically looks good to me 👍

Comment on lines 31 to 38
private final ServerMetrics serverMetrics;

/**
* Creates a new instance.
*/
GracefulShutdownSupport(ServerMetrics serverMetrics) {
this.serverMetrics = serverMetrics;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit; member fields/constructors can go under the static declarations

https://armeria.dev/community/developer-guide#organize

Copy link
Author

Choose a reason for hiding this comment

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

I have made the corrections! I will be more careful with the order next time

/**
* Creates a new instance.
*/
GracefulShutdownSupport(ServerMetrics serverMetrics) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be private, ditto for the other ctors

Suggested change
GracefulShutdownSupport(ServerMetrics serverMetrics) {
private GracefulShutdownSupport(ServerMetrics serverMetrics) {

Copy link
Author

Choose a reason for hiding this comment

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

I have changed it to private

@@ -174,6 +190,10 @@ public void bindTo(MeterRegistry meterRegistry) {
meterRegistry.gauge(allRequestsMeterName,
ImmutableList.of(Tag.of("protocol", "http1.websocket"), Tag.of("state", "active")),
activeHttp1WebSocketRequests);
// pending non-transient responses
meterRegistry.gauge(allRequestsMeterName,
Copy link
Contributor

Choose a reason for hiding this comment

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

Question) Can we keep the old format (armeria.server.pending.responses) so that metric name related breaking changes aren't made?

Copy link
Author

Choose a reason for hiding this comment

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

I have changed it to the old format

@jrhee17 jrhee17 added this to the 1.31.0 milestone Sep 9, 2024
@jrhee17
Copy link
Contributor

jrhee17 commented Sep 9, 2024

Can you also sign the CLA? #5895 (comment)

@EunJungYoo
Copy link
Author

Can you also sign the CLA? #5895 (comment)
I have finished signing the CLA

Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

Added a minor commit, let me know if anything doesn't make sense. Thanks @EunJungYoo 🙇 👍

Comment on lines +164 to +170
void increasePendingResponses() {
pendingResponses.increment();
}

void decreasePendingResponses() {
pendingResponses.decrement();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The number of pendingResponses seems the same as activeRequests. If so, we don't need to record the same value twice in different places.

Should we remove inc() and dec() in GracefulShutdownSupport and use activeRequests() for "armeria.server.pending.responses"

Copy link
Author

Choose a reason for hiding this comment

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

#5627 (comment)

There was a previous mention of the difference between pendingResponses and activeRequests. If we were to merge them, additional modifications might be necessary. Would it be better to merge them?

Copy link
Contributor

Choose a reason for hiding this comment

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

The current changes are a clean-up but do not provide additional benefits to users.

I prefer to add metrics for transient requests in ServerMetrics

  • Expose a meter with state=transient tag for TransientService
  • Exclude transient requests from activeRequests
  • Switch state=pending to state=active or state=transient
  • Add useful methods
    public long transientHttp1Requests() {
        return transientHttp1Requests.longValue();
    }
    
    public long transientHttp2Requests() {
        return transientHttp2Requests.longValue();
    }
    
    public long transientRequests() {
        return transientHttp1Requests() + transientHttp2Requests();
    }
    
    public long allRequests() {
        return pendingRequests() + activeRequests() + transientRequests();
    }

After those changes, pendingResponses will be the same as activeRequests.

Copy link
Member

Choose a reason for hiding this comment

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

@ikhoon That's a good suggestion. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pendingResponses to ServerMetrics
5 participants