ajamato commented on a change in pull request #15183:
URL: https://github.com/apache/beam/pull/15183#discussion_r678589703



##########
File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/datastore/DatastoreV1.java
##########
@@ -901,12 +907,28 @@ private RunQueryResponse 
runQueryWithRetries(RunQueryRequest request) throws Exc
         Sleeper sleeper = Sleeper.DEFAULT;
         BackOff backoff = RUNQUERY_BACKOFF.backoff();
         while (true) {
+          HashMap<String, String> baseLabels = new HashMap<>();
+          baseLabels.put(MonitoringInfoConstants.Labels.PTRANSFORM, "TODO");
+          baseLabels.put(MonitoringInfoConstants.Labels.SERVICE, "Datastore");
+          baseLabels.put(MonitoringInfoConstants.Labels.METHOD, 
"runQueryWithRetries");
+          baseLabels.put(MonitoringInfoConstants.Labels.RESOURCE, "TODO");
+          baseLabels.put(
+              MonitoringInfoConstants.Labels.BIGQUERY_PROJECT_ID, 
request.getProjectId());
+          ServiceCallMetric serviceCallMetric =
+              new 
ServiceCallMetric(MonitoringInfoConstants.Urns.API_REQUEST_COUNT, baseLabels);
           try {
             RunQueryResponse response = datastore.runQuery(request);
+            serviceCallMetric.call("ok");
             rpcSuccesses.inc();
             return response;
           } catch (DatastoreException exception) {
             rpcErrors.inc();
+            GoogleJsonError.ErrorInfo errorInfo = getErrorInfo(exception);
+            if (errorInfo == null) {
+              
serviceCallMetric.call(ServiceCallMetric.CANONICAL_STATUS_UNKNOWN);
+              throw exception;
+            }
+            serviceCallMetric.call(errorInfo.getReason());

Review comment:
       Lets make sure we run an integration test and exercise the error case 
before submitting.
   
   I started a thread with the dev list. To see if anyone knows how to run the 
test.
   You should be able to verify by
   1. First run it normally.
   2. Run it again by inducing an error (i.e trying to read from something that 
doesnt exist)
   Add some logging to veirfy your code is called.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to