Skip to content

Add pendingResponse to ServerMetrics - #5895

Open
warmth424 wants to merge 3 commits into
line:mainfrom
warmth424:issue-5666
Open

Add pendingResponse to ServerMetrics#5895
warmth424 wants to merge 3 commits into
line:mainfrom
warmth424:issue-5666

Conversation

@warmth424

Copy link
Copy Markdown

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

CLAassistant commented Sep 7, 2024

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Sep 7, 2024

Copy link
Copy Markdown

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.

@jrhee17 jrhee17 left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

ImmutableList.of(Tag.of("protocol", "http1.websocket"), Tag.of("state", "active")),
activeHttp1WebSocketRequests);
// pending non-transient responses
meterRegistry.gauge(allRequestsMeterName,

Copy link
Copy Markdown
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
Copy Markdown
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

jrhee17 commented Sep 9, 2024

Copy link
Copy Markdown
Contributor

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

@warmth424

Copy link
Copy Markdown
Author

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

@jrhee17 jrhee17 left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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. 👍

@github-actions github-actions Bot added the Stale label Oct 25, 2024
@jrhee17 jrhee17 modified the milestones: 1.31.0, 1.32.0 Nov 5, 2024
@github-actions github-actions Bot removed the Stale label Nov 6, 2024
@github-actions github-actions Bot added the Stale label Dec 6, 2024
@minwoox minwoox modified the milestones: 1.32.0, 1.33.0 Feb 11, 2025
@github-actions github-actions Bot removed the Stale label Feb 15, 2025
@github-actions github-actions Bot added the Stale label Mar 23, 2025
@ikhoon ikhoon modified the milestones: 1.33.0, 1.34.0 Aug 1, 2025
@github-actions github-actions Bot removed the Stale label Aug 3, 2025
@github-actions github-actions Bot added the Stale label Sep 7, 2025
@jrhee17 jrhee17 modified the milestones: 1.34.0, 1.35.0 Nov 24, 2025
@github-actions github-actions Bot removed the Stale label Nov 26, 2025
@github-actions github-actions Bot added the Stale label Dec 28, 2025
@minwoox minwoox modified the milestones: 1.35.0, 1.36.0 Dec 30, 2025
@github-actions github-actions Bot removed the Stale label Jan 3, 2026
@ikhoon ikhoon modified the milestones: 1.36.0, 1.37.0 Feb 2, 2026
@github-actions github-actions Bot added the Stale label Mar 8, 2026
@ikhoon ikhoon modified the milestones: 1.38.0, 1.39.0 Apr 3, 2026
@github-actions github-actions Bot removed the Stale label Apr 6, 2026
@minwoox minwoox modified the milestones: 1.39.0, 1.40.0 May 8, 2026
@jrhee17 jrhee17 modified the milestones: 1.40.0, 1.41.0 Jun 10, 2026
@github-actions github-actions Bot added the Stale label Jul 11, 2026
@ikhoon ikhoon modified the milestones: 1.41.0, 1.42.0 Aug 4, 2026
@github-actions github-actions Bot removed the Stale label Aug 9, 2026
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