You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/01/18 17:33:00 UTC
[GitHub] [beam] lukecwik commented on a change in pull request #16547: [BEAM-13665] Fix SpannerIO NPE when projectID is not specified
lukecwik commented on a change in pull request #16547:
URL: https://github.com/apache/beam/pull/16547#discussion_r786997483
##########
File path: sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/BatchSpannerRead.java
##########
@@ -193,15 +193,16 @@ public void processElement(ProcessContext c) throws Exception {
}
private ServiceCallMetric createServiceCallMetric(
- String projectId, String databaseId, String tableId) {
+ @Nullable String projectId, String databaseId, String tableId) {
HashMap<String, String> baseLabels = new HashMap<>();
baseLabels.put(MonitoringInfoConstants.Labels.PTRANSFORM, "");
baseLabels.put(MonitoringInfoConstants.Labels.SERVICE, "Spanner");
baseLabels.put(MonitoringInfoConstants.Labels.METHOD, "Read");
baseLabels.put(
MonitoringInfoConstants.Labels.RESOURCE,
GcpResourceIdentifiers.spannerTable(projectId, databaseId, tableId));
- baseLabels.put(MonitoringInfoConstants.Labels.SPANNER_PROJECT_ID, projectId);
+ baseLabels.put(
+ MonitoringInfoConstants.Labels.SPANNER_PROJECT_ID, (projectId == null ? "" : projectId));
Review comment:
Is there a reason we aren't using the same project id that SpannerOptions relies on [ServiceOptions#getDefaultProjectId](https://googleapis.dev/java/google-cloud-clients/0.97.0-alpha/com/google/cloud/ServiceOptions.Builder.html#setProjectId-java.lang.String-) if the value provider hasn't set it?
We want to make sure we keep the existing behavior of getting the default project id within the execution environment and not when the pipeline is being constructed (unless there is a strong reason for the swap).
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org