Skip to content

Commit

Permalink
Added standard logging when exception is thrown (#17717)
Browse files Browse the repository at this point in the history
Updated BatchSpannerRead.java with standard logging for exception.
  • Loading branch information
Alejandro Rodriguez-Morantes authored May 26, 2022
1 parent ff39fcb commit 7c92e8c
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import org.apache.beam.sdk.values.PCollectionView;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* This transform reads from Cloud Spanner using the {@link com.google.cloud.spanner.BatchClient}.
Expand All @@ -52,6 +54,7 @@
})
abstract class BatchSpannerRead
extends PTransform<PCollection<ReadOperation>, PCollection<Struct>> {
private static final Logger LOG = LoggerFactory.getLogger(BatchSpannerRead.class);

public static BatchSpannerRead create(
SpannerConfig spannerConfig,
Expand Down Expand Up @@ -228,6 +231,7 @@ public void processElement(ProcessContext c) throws Exception {
}
} catch (SpannerException e) {
serviceCallMetric.call(e.getErrorCode().getGrpcStatusCode().toString());
LOG.error("Error while processing element", e);
throw (e);
}
serviceCallMetric.call("ok");
Expand Down

0 comments on commit 7c92e8c

Please sign in to comment.