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

Expose inbound.cancels.{requested,honored} metrics #912

Conversation

vpranckaitis
Copy link
Contributor

This commit adds inbound.cancels.requested and inbound.cancels.honored metrics. The documentation mentions these metrics, but they were not yet implemented.

@CLAassistant
Copy link

CLAassistant commented Jan 17, 2024

CLA assistant check
All committers have signed the CLA.

@vpranckaitis vpranckaitis marked this pull request as ready for review January 17, 2024 07:36
@vpranckaitis
Copy link
Contributor Author

cc: @prashantv

@vpranckaitis
Copy link
Contributor Author

Note that I couldn't run all the tests locally, because of the missing thrift-v1.0.0-dev/thrift-1-darwin-arm64.tar.gz binary for M1 Mac:

> make test 

<...>

scripts/install-thrift.sh /Users/vilius/go/src/github.com/vpranckaitis/tchannel-go/.bin
--2024-01-17 09:25:27--  https://github.com/uber/tchannel-go/releases/download/thrift-v1.0.0-dev/thrift-1-darwin-arm64.tar.gz
Resolving github.com (github.com)... 140.82.121.4
Connecting to github.com (github.com)|140.82.121.4|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2024-01-17 09:25:27 ERROR 404: Not Found.

Copy link
Contributor

@prashantv prashantv left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

codecov bot commented Feb 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7576b14) 89.25% compared to head (e39a740) 89.19%.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #912      +/-   ##
==========================================
- Coverage   89.25%   89.19%   -0.07%     
==========================================
  Files          43       43              
  Lines        4515     4517       +2     
==========================================
- Hits         4030     4029       -1     
+ Misses        370      369       -1     
- Partials      115      119       +4     

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

@@ -519,16 +522,22 @@ func TestServerClientCancellation(t *testing.T) {
_, _, _, err := raw.Call(ctx, ts.Server(), ts.HostPort(), ts.ServiceName(), "ctxWait", nil, nil)
assert.Equal(t, ErrRequestCancelled, err, "client call result")

serverStats.Expected.IncCounter("inbound.cancels.requested", ts.Server().StatsTags(), 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: .StatsTags() allocates, so should call just once (not a big deal in tests, but still good practice)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -568,6 +581,13 @@ func TestCancelWithoutSendCancelOnContextCanceled(t *testing.T) {
_, _, _, err := raw.Call(ctx, ts.Server(), ts.HostPort(), ts.ServiceName(), "ctxWait", nil, nil)
assert.Equal(t, ErrRequestCancelled, err, "client call result")

if tt.wantCancelRequested {
serverStats.Expected.IncCounter("inbound.cancels.requested", ts.Server().StatsTags(), 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

are we missing a call to serverStats.ValidateExpected(t) below?

Copy link
Contributor Author

@vpranckaitis vpranckaitis Feb 9, 2024

Choose a reason for hiding this comment

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

Yes, it's missing the ValidateExpected(). However, tried adding it below and the test wouldn't pass, because:

  1. the with_relay subtest inside WithTestServer doesn't propagate the cancellation, thus the metric is never incremented;
  2. the no_relay subtest insde WithTestServer increases the metric, but it happens not immediately upon cancel, only after the function passed into WithTestServer is finished executing.

I'm not yet sure how to solve this cleanly. I will dig deeper into this once I have more time.

Copy link
Contributor Author

@vpranckaitis vpranckaitis Feb 9, 2024

Choose a reason for hiding this comment

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

This seems to be working (93cd04f). Please feel free to suggest a different approach.

@cinchurge
Copy link
Collaborator

bump?

Copy link
Collaborator

@cinchurge cinchurge left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@vpranckaitis
Copy link
Contributor Author

@cinchurge there was a Lint failure due to missing comment for a method. I've added it in e39a740, need to rerun the CI.

@cinchurge cinchurge merged commit 41f6ba3 into uber:dev Feb 16, 2024
4 checks passed
cinchurge added a commit that referenced this pull request Feb 20, 2024
### Added

 * Expose `inbound.cancels.{requested,honored}` metrics (#912)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants