-
Notifications
You must be signed in to change notification settings - Fork 651
Fix client metrics recording on round trip error #7146
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?
Fix client metrics recording on round trip error #7146
Conversation
Duplicating code like isn't really maintainable long-term. We should be able to have the metrics recorded, with no code duplication. Possibly, by exporting the metric into its own method. Also, this needs to be tested. |
Thank you for the review @dmathieu What do you think of my latest commit? I’ve added a method to record metrics and removed most of the unnecessary code duplication. Thank you. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7146 +/- ##
======================================
Coverage 75.8% 75.8%
======================================
Files 207 206 -1
Lines 19484 19258 -226
======================================
- Hits 14783 14612 -171
+ Misses 4265 4213 -52
+ Partials 436 433 -3
🚀 New features to boost your workflow:
|
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.
Could you add a test?
metricOpts := t.semconv.MetricOptions(metricAttributes) | ||
|
||
// set transport record metrics | ||
t.recordMetrics(ctx, requestStartTime, metricData, metricOpts) |
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.
How about calling this before the error check, in a defer
statement?
Thank you for the review @dmathieu Please check my latest commit. Thank you! |
This pull request fixes client metrics recording on round trip error
Related issues: #6940
Does this approach correctly address the issue with round trip errors?
Should I add specific tests to verify metric recording (
http.client.duration
) during round trip errors?