-
Notifications
You must be signed in to change notification settings - Fork 9
added error count of failed requests from query service to pinot #138
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
Changes from 1 commit
6e3be19
84d249e
c0df366
2eb6185
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,9 +2,11 @@ | |
|
|
||
| import static org.hypertrace.core.query.service.RowChunkingOperator.chunkRows; | ||
|
|
||
| import com.google.common.collect.ImmutableMap; | ||
| import io.grpc.Status; | ||
| import io.grpc.stub.ServerCallStreamObserver; | ||
| import io.grpc.stub.StreamObserver; | ||
| import io.micrometer.core.instrument.Counter; | ||
| import io.reactivex.rxjava3.core.Maybe; | ||
| import io.reactivex.rxjava3.core.Observable; | ||
| import javax.inject.Inject; | ||
|
|
@@ -16,14 +18,32 @@ | |
| import org.hypertrace.core.query.service.api.QueryServiceGrpc; | ||
| import org.hypertrace.core.query.service.api.ResultSetChunk; | ||
| import org.hypertrace.core.query.service.validation.QueryValidator; | ||
| import org.hypertrace.core.serviceframework.metrics.PlatformMetricsRegistry; | ||
|
|
||
| @Singleton | ||
| @Slf4j | ||
| class QueryServiceImpl extends QueryServiceGrpc.QueryServiceImplBase { | ||
|
|
||
| private final RequestHandlerSelector handlerSelector; | ||
| private final QueryTransformationPipeline queryTransformationPipeline; | ||
| private final QueryValidator queryValidator; | ||
|
|
||
| private Counter serviceResponseErrorCounter; | ||
|
|
||
| class QueryServiceObserver<T> extends ServerCallStreamRxObserver<T> { | ||
|
|
||
| public QueryServiceObserver(StreamObserver<T> serverCallStreamObserver) { | ||
| super(serverCallStreamObserver); | ||
| } | ||
|
|
||
| @Override | ||
| public void onError(Throwable th) { | ||
| serviceResponseErrorCounter.increment(); | ||
| super.onError(th); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| @Inject | ||
| public QueryServiceImpl( | ||
| RequestHandlerSelector handlerSelector, | ||
|
|
@@ -32,6 +52,15 @@ public QueryServiceImpl( | |
| this.handlerSelector = handlerSelector; | ||
| this.queryTransformationPipeline = queryTransformationPipeline; | ||
| this.queryValidator = queryValidator; | ||
| initMetrics(); | ||
| } | ||
|
|
||
| private static final String COUNTER_NAME = "hypertrace.query-service.response.errors"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved them. |
||
|
|
||
| private void initMetrics() { | ||
| serviceResponseErrorCounter = | ||
| PlatformMetricsRegistry.registerCounter( | ||
| COUNTER_NAME, ImmutableMap.of()); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -47,7 +76,7 @@ public void execute( | |
| originalRequest, requestContext.getTenantId().orElseThrow()))) | ||
| .doOnError(error -> log.error("Query failed: {}", originalRequest, error)) | ||
| .subscribe( | ||
| new ServerCallStreamRxObserver<>( | ||
| new QueryServiceObserver<>( | ||
| (ServerCallStreamObserver<ResultSetChunk>) callStreamObserver)); | ||
| } | ||
|
|
||
|
|
||
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.
Can you move this to a separate file?
Would it make sense to move
org.hypertrace.core.grpcutils.server.rxof repo https://github.com/hypertrace/java-grpc-utils/tree/main/grpc-server-rx-utils? Something like as belowclass ServerCallStreamRxObserverWihMetricRecorder<T> extends ServerCallStreamRxObserver<T>?cc: @aaron-steinfeld
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.
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.
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.
hmmmm... Okay, I got your point. Made the change.
Can you check again? Let me know if it's fine.