Skip to content

Conversation

@Harnoor-se7en
Copy link
Contributor

@Harnoor-se7en Harnoor-se7en commented Apr 7, 2022

Description

Currently, there are no metrics to track the number of failed requests in the data query layer. Adding an error counter to track requests failing in query service. The metric is exposed on /metrics endpoint.

For gateway-service - https://github.com/hypertrace/gateway-service/pull/128

@Harnoor-se7en Harnoor-se7en requested a review from a team April 7, 2022 12:23
initMetrics();
}

private static final String COUNTER_NAME = "hypertrace.query-service.response.errors";

Choose a reason for hiding this comment

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

Move these declarations to the top of the class. And move the inner class defn down. Can you check if the formatter does this automatically?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved them.

@codecov
Copy link

codecov bot commented Apr 7, 2022

Codecov Report

Merging #138 (2eb6185) into main (bc43b70) will increase coverage by 0.09%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##               main     #138      +/-   ##
============================================
+ Coverage     81.90%   82.00%   +0.09%     
- Complexity      609      611       +2     
============================================
  Files            62       62              
  Lines          2327     2339      +12     
  Branches        240      240              
============================================
+ Hits           1906     1918      +12     
  Misses          326      326              
  Partials         95       95              
Flag Coverage Δ
integration 82.00% <100.00%> (+0.09%) ⬆️
unit 79.67% <100.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ypertrace/core/query/service/QueryServiceImpl.java 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc43b70...2eb6185. Read the comment docs.

@Harnoor-se7en
Copy link
Contributor Author

adding some further commits based on the feedback will reopen the PR later.


private Counter serviceResponseErrorCounter;
private Counter serviceResponseSuccessCounter;
private static final String ERROR_COUNTER_NAME = "hypertrace.query-service.response.errors";
Copy link
Contributor

Choose a reason for hiding this comment

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

See the comment on your other PR - https://github.com/hypertrace/gateway-service/pull/128/files#r854786951
Shall we go with?
hypertrace.query.service.request.status {"error"="true"}
hypertrace.query.service.request.status {"error"="false"}

Copy link
Contributor

Choose a reason for hiding this comment

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

Please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, making this change.

private static final String ERROR_COUNTER_NAME = "hypertrace.query-service.response.errors";
private static final String SUCCESS_COUNTER_NAME = "hypertrace.query-service.response.success";

class QueryServiceObserver<T> extends ServerCallStreamRxObserver<T> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move this to a separate file?

Would it make sense to move org.hypertrace.core.grpcutils.server.rx of repo https://github.com/hypertrace/java-grpc-utils/tree/main/grpc-server-rx-utils? Something like as below

class ServerCallStreamRxObserverWihMetricRecorder<T> extends ServerCallStreamRxObserver<T> ?

cc: @aaron-steinfeld

Copy link
Contributor

Choose a reason for hiding this comment

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

If it were me, I probably wouldn't use the subscription to do this - you only get one (or in some cases, none, if you're not at a terminal op). Extending classes, and introducing classes that themselves may be extended, inevitably leads to more coupling. Instead, taking functional programming to heart, I would prefer composition here. That is, using either doOnError + doOnNext, or doOnEach (which can accept its own observer, or individual callbacks).

In short, this is an exercise in SRP - we can use two individual observers to accomplish the same thing in a clearer and more maintainable way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmmmm... Okay, I got your point. Made the change.
Can you check again? Let me know if it's fine.

Copy link
Contributor

@aaron-steinfeld aaron-steinfeld left a comment

Choose a reason for hiding this comment

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

lgtm. Will let @kotharironak approve to ensure it's in line with the other metric change.

Copy link
Contributor

@kotharironak kotharironak left a comment

Choose a reason for hiding this comment

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

lgtm

@kotharironak
Copy link
Contributor

@Harnoor-se7en Merging this, will cut the release after fixing snyk issue - https://github.com/hypertrace/query-service/runs/6129549813?check_suite_focus=true

@kotharironak kotharironak merged commit 8cd829c into hypertrace:main Apr 23, 2022
@github-actions
Copy link

Unit Test Results

  35 files  ±0    35 suites  ±0   12s ⏱️ +5s
200 tests ±0  200 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 8cd829c. ± Comparison against base commit bc43b70.

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