Skip to content

Commit 4bf7a67

Browse files
authored
Merge branch 'main' into generate-libraries-main
2 parents faf3b63 + cd76c73 commit 4bf7a67

File tree

81 files changed

+4258
-1194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+4258
-1194
lines changed

.kokoro/build.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ integration)
9898
-Dclirr.skip=true \
9999
-Denforcer.skip=true \
100100
-Dmaven.main.skip=true \
101-
-Dspanner.gce.config.project_id=gcloud-devel \
102-
-Dspanner.testenv.instance=projects/gcloud-devel/instances/java-client-integration-tests \
101+
-Dspanner.gce.config.server_url=https://staging-wrenchworks.sandbox.googleapis.com \
102+
-Dspanner.gce.config.project_id=span-cloud-testing \
103+
-Dspanner.testenv.instance=projects/span-cloud-testing/instances/java-client-integration-tests \
103104
-fae \
104105
verify
105106
RETURN_CODE=$?
@@ -113,6 +114,7 @@ integration-directpath-enabled)
113114
-Dclirr.skip=true \
114115
-Denforcer.skip=true \
115116
-Dmaven.main.skip=true \
117+
-Dspanner.gce.config.server_url=https://staging-wrenchworks.sandbox.googleapis.com \
116118
-Dspanner.testenv.instance=projects/span-cloud-testing/instances/spanner-java-client-directpath \
117119
-Dspanner.gce.config.project_id=span-cloud-testing \
118120
-fae \
@@ -128,8 +130,9 @@ integration-multiplexed-sessions-enabled)
128130
-Dclirr.skip=true \
129131
-Denforcer.skip=true \
130132
-Dmaven.main.skip=true \
131-
-Dspanner.gce.config.project_id=gcloud-devel \
132-
-Dspanner.testenv.instance=projects/gcloud-devel/instances/java-client-integration-tests-multiplexed-sessions \
133+
-Dspanner.gce.config.server_url=https://staging-wrenchworks.sandbox.googleapis.com \
134+
-Dspanner.gce.config.project_id=span-cloud-testing \
135+
-Dspanner.testenv.instance=projects/span-cloud-testing/instances/java-client-integration-tests-multiplexed-sessions \
133136
-fae \
134137
verify
135138
RETURN_CODE=$?

.kokoro/presubmit/integration-directpath-enabled.cfg

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@ env_vars: {
1111
value: "integration-directpath-enabled"
1212
}
1313

14-
# TODO: remove this after we've migrated all tests and scripts
15-
env_vars: {
16-
key: "GCLOUD_PROJECT"
17-
value: "gcloud-devel"
18-
}
19-
20-
env_vars: {
21-
key: "GOOGLE_CLOUD_PROJECT"
22-
value: "gcloud-devel"
23-
}
24-
2514
env_vars: {
2615
key: "GOOGLE_APPLICATION_CREDENTIALS"
2716
value: "secret_manager/java-client-testing"

.kokoro/presubmit/integration-multiplexed-sessions-enabled.cfg

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,14 @@ env_vars: {
1111
value: "integration-multiplexed-sessions-enabled"
1212
}
1313

14-
# TODO: remove this after we've migrated all tests and scripts
15-
env_vars: {
16-
key: "GCLOUD_PROJECT"
17-
value: "gcloud-devel"
18-
}
19-
20-
env_vars: {
21-
key: "GOOGLE_CLOUD_PROJECT"
22-
value: "gcloud-devel"
23-
}
24-
2514
env_vars: {
2615
key: "GOOGLE_APPLICATION_CREDENTIALS"
27-
value: "secret_manager/java-it-service-account"
16+
value: "secret_manager/java-client-testing"
2817
}
2918

3019
env_vars: {
3120
key: "SECRET_MANAGER_KEYS"
32-
value: "java-it-service-account"
21+
value: "java-client-testing"
3322
}
3423

3524
env_vars: {

.kokoro/presubmit/integration.cfg

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,12 @@ env_vars: {
1111
value: "integration"
1212
}
1313

14-
# TODO: remove this after we've migrated all tests and scripts
15-
env_vars: {
16-
key: "GCLOUD_PROJECT"
17-
value: "gcloud-devel"
18-
}
19-
20-
env_vars: {
21-
key: "GOOGLE_CLOUD_PROJECT"
22-
value: "gcloud-devel"
23-
}
24-
2514
env_vars: {
2615
key: "GOOGLE_APPLICATION_CREDENTIALS"
27-
value: "secret_manager/java-it-service-account"
16+
value: "secret_manager/java-client-testing"
2817
}
2918

3019
env_vars: {
3120
key: "SECRET_MANAGER_KEYS"
32-
value: "java-it-service-account"
21+
value: "java-client-testing"
3322
}
34-

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file:
1919
<dependency>
2020
<groupId>com.google.cloud</groupId>
2121
<artifactId>libraries-bom</artifactId>
22-
<version>26.54.0</version>
22+
<version>26.57.0</version>
2323
<type>pom</type>
2424
<scope>import</scope>
2525
</dependency>
@@ -525,6 +525,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-spanner/tree/
525525
| Create Sequence Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateSequenceSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateSequenceSample.java) |
526526
| Create Table With Foreign Key Delete Cascade Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateTableWithForeignKeyDeleteCascadeSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateTableWithForeignKeyDeleteCascadeSample.java) |
527527
| Custom Timeout And Retry Settings Example | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CustomTimeoutAndRetrySettingsExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CustomTimeoutAndRetrySettingsExample.java) |
528+
| Database Add Split Points Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/DatabaseAddSplitPointsSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/DatabaseAddSplitPointsSample.java) |
528529
| Delete Backup Schedule Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/DeleteBackupScheduleSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/DeleteBackupScheduleSample.java) |
529530
| Delete Instance Config Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/DeleteInstanceConfigSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/DeleteInstanceConfigSample.java) |
530531
| Delete Using Dml Returning Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/DeleteUsingDmlReturningSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/DeleteUsingDmlReturningSample.java) |

google-cloud-spanner/clirr-ignored-differences.xml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,13 @@
751751
<method>boolean isEnableBuiltInMetrics()</method>
752752
</difference>
753753

754+
<!-- Added Built In GRPC Metrics option -->
755+
<difference>
756+
<differenceType>7012</differenceType>
757+
<className>com/google/cloud/spanner/SpannerOptions$SpannerEnvironment</className>
758+
<method>boolean isEnableGRPCBuiltInMetrics()</method>
759+
</difference>
760+
754761
<!-- Added Monitoring host option -->
755762
<difference>
756763
<differenceType>7012</differenceType>
@@ -807,7 +814,7 @@
807814
<className>com/google/cloud/spanner/connection/Connection</className>
808815
<method>boolean isKeepTransactionAlive()</method>
809816
</difference>
810-
817+
811818
<!-- Automatic DML batching -->
812819
<difference>
813820
<differenceType>7012</differenceType>
@@ -839,7 +846,7 @@
839846
<className>com/google/cloud/spanner/connection/Connection</className>
840847
<method>boolean isAutoBatchDmlUpdateCountVerification()</method>
841848
</difference>
842-
849+
843850
<!-- Retry DML as Partitioned DML -->
844851
<difference>
845852
<differenceType>7012</differenceType>
@@ -863,7 +870,7 @@
863870
<className>com/google/cloud/spanner/connection/Connection</className>
864871
<method>java.lang.Object runTransaction(com.google.cloud.spanner.connection.Connection$TransactionCallable)</method>
865872
</difference>
866-
873+
867874
<!-- Added experimental host option -->
868875
<difference>
869876
<differenceType>7012</differenceType>
@@ -927,5 +934,27 @@
927934
<className>com/google/cloud/spanner/connection/ConnectionOptions</className>
928935
<field>VALID_PROPERTIES</field>
929936
</difference>
930-
937+
938+
<!-- Remove supportsExplain() from the parser -->
939+
<difference>
940+
<differenceType>7002</differenceType>
941+
<className>com/google/cloud/spanner/connection/AbstractStatementParser</className>
942+
<method>boolean supportsExplain()</method>
943+
</difference>
944+
<difference>
945+
<differenceType>7002</differenceType>
946+
<className>com/google/cloud/spanner/connection/PostgreSQLStatementParser</className>
947+
<method>boolean supportsExplain()</method>
948+
</difference>
949+
<difference>
950+
<differenceType>7002</differenceType>
951+
<className>com/google/cloud/spanner/connection/SpannerStatementParser</className>
952+
<method>boolean supportsExplain()</method>
953+
</difference>
954+
955+
<difference>
956+
<differenceType>7012</differenceType>
957+
<className>com/google/cloud/spanner/DatabaseClient</className>
958+
<method>com.google.cloud.spanner.Statement$StatementFactory getStatementFactory()</method>
959+
</difference>
931960
</differences>

google-cloud-spanner/pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@
191191
<groupId>io.grpc</groupId>
192192
<artifactId>grpc-stub</artifactId>
193193
</dependency>
194+
<dependency>
195+
<groupId>io.grpc</groupId>
196+
<artifactId>grpc-opentelemetry</artifactId>
197+
</dependency>
194198
<dependency>
195199
<groupId>com.google.api</groupId>
196200
<artifactId>api-common</artifactId>
@@ -517,6 +521,19 @@
517521
</execution>
518522
</executions>
519523
</plugin>
524+
<plugin>
525+
<groupId>org.apache.maven.plugins</groupId>
526+
<artifactId>maven-compiler-plugin</artifactId>
527+
<configuration>
528+
<annotationProcessorPaths>
529+
<path>
530+
<groupId>org.openjdk.jmh</groupId>
531+
<artifactId>jmh-generator-annprocess</artifactId>
532+
<version>1.37</version>
533+
</path>
534+
</annotationProcessorPaths>
535+
</configuration>
536+
</plugin>
520537
</plugins>
521538
</build>
522539
</profile>

google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbortedException.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,17 @@ public class AbortedException extends SpannerException {
3535
/** Private constructor. Use {@link SpannerExceptionFactory} to create instances. */
3636
AbortedException(
3737
DoNotConstructDirectly token, @Nullable String message, @Nullable Throwable cause) {
38-
this(token, message, cause, null);
38+
this(token, message, cause, null, null);
3939
}
4040

4141
/** Private constructor. Use {@link SpannerExceptionFactory} to create instances. */
4242
AbortedException(
4343
DoNotConstructDirectly token,
4444
@Nullable String message,
4545
@Nullable Throwable cause,
46-
@Nullable ApiException apiException) {
47-
super(token, ErrorCode.ABORTED, IS_RETRYABLE, message, cause, apiException);
46+
@Nullable ApiException apiException,
47+
@Nullable XGoogSpannerRequestId reqId) {
48+
super(token, ErrorCode.ABORTED, IS_RETRYABLE, message, cause, apiException, reqId);
4849
}
4950

5051
/**

google-cloud-spanner/src/main/java/com/google/cloud/spanner/AdminRequestsPerMinuteExceededException.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ public class AdminRequestsPerMinuteExceededException extends SpannerException {
3232
/** Private constructor. Use {@link SpannerExceptionFactory} to create instances. */
3333
AdminRequestsPerMinuteExceededException(
3434
DoNotConstructDirectly token, @Nullable String message, @Nullable Throwable cause) {
35-
this(token, message, cause, null);
35+
this(token, message, cause, null, null);
3636
}
3737

3838
/** Private constructor. Use {@link SpannerExceptionFactory} to create instances. */
3939
AdminRequestsPerMinuteExceededException(
4040
DoNotConstructDirectly token,
4141
@Nullable String message,
4242
@Nullable Throwable cause,
43-
@Nullable ApiException apiException) {
44-
super(token, ErrorCode.RESOURCE_EXHAUSTED, true, message, cause, apiException);
43+
@Nullable ApiException apiException,
44+
@Nullable XGoogSpannerRequestId reqId) {
45+
super(token, ErrorCode.RESOURCE_EXHAUSTED, true, message, cause, apiException, reqId);
4546
}
4647
}

google-cloud-spanner/src/main/java/com/google/cloud/spanner/BuiltInMetricsConstant.java

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import io.opentelemetry.sdk.metrics.InstrumentSelector;
2727
import io.opentelemetry.sdk.metrics.InstrumentType;
2828
import io.opentelemetry.sdk.metrics.View;
29+
import java.util.Collection;
2930
import java.util.Map;
3031
import java.util.Set;
3132
import java.util.stream.Collectors;
@@ -36,6 +37,7 @@ public class BuiltInMetricsConstant {
3637
public static final String METER_NAME = "spanner.googleapis.com/internal/client";
3738
public static final String GAX_METER_NAME = OpenTelemetryMetricsRecorder.GAX_METER_NAME;
3839
static final String SPANNER_METER_NAME = "spanner-java";
40+
static final String GRPC_METER_NAME = "grpc-java";
3941
static final String GFE_LATENCIES_NAME = "gfe_latencies";
4042
static final String OPERATION_LATENCIES_NAME = "operation_latencies";
4143
static final String ATTEMPT_LATENCIES_NAME = "attempt_latencies";
@@ -55,6 +57,14 @@ public class BuiltInMetricsConstant {
5557
.map(m -> METER_NAME + '/' + m)
5658
.collect(Collectors.toSet());
5759

60+
static final Collection<String> GRPC_METRICS_TO_ENABLE =
61+
ImmutableList.of(
62+
"grpc.lb.rls.default_target_picks",
63+
"grpc.lb.rls.target_picks",
64+
"grpc.xds_client.server_failure",
65+
"grpc.xds_client.resource_updates_invalid",
66+
"grpc.xds_client.resource_updates_valid");
67+
5868
public static final String SPANNER_RESOURCE_TYPE = "spanner_instance_client";
5969

6070
public static final AttributeKey<String> PROJECT_ID_KEY = AttributeKey.stringKey("project_id");
@@ -66,12 +76,7 @@ public class BuiltInMetricsConstant {
6676

6777
// These metric labels will be promoted to the spanner monitored resource fields
6878
public static final Set<AttributeKey<String>> SPANNER_PROMOTED_RESOURCE_LABELS =
69-
ImmutableSet.of(
70-
PROJECT_ID_KEY,
71-
INSTANCE_ID_KEY,
72-
INSTANCE_CONFIG_ID_KEY,
73-
LOCATION_ID_KEY,
74-
CLIENT_HASH_KEY);
79+
ImmutableSet.of(INSTANCE_ID_KEY);
7580

7681
public static final AttributeKey<String> DATABASE_KEY = AttributeKey.stringKey("database");
7782
public static final AttributeKey<String> CLIENT_UID_KEY = AttributeKey.stringKey("client_uid");
@@ -102,6 +107,9 @@ public class BuiltInMetricsConstant {
102107
DIRECT_PATH_ENABLED_KEY,
103108
DIRECT_PATH_USED_KEY);
104109

110+
static final Set<String> GRPC_LB_RLS_ATTRIBUTES =
111+
ImmutableSet.of("grpc.lb.rls.data_plane_target", "grpc.lb.pick_result");
112+
105113
static Aggregation AGGREGATION_WITH_MILLIS_HISTOGRAM =
106114
Aggregation.explicitBucketHistogram(
107115
ImmutableList.of(
@@ -111,6 +119,14 @@ public class BuiltInMetricsConstant {
111119
10000.0, 20000.0, 50000.0, 100000.0, 200000.0, 400000.0, 800000.0, 1600000.0,
112120
3200000.0));
113121

122+
static final Collection<String> GRPC_METRICS_ENABLED_BY_DEFAULT =
123+
ImmutableList.of(
124+
"grpc.client.attempt.sent_total_compressed_message_size",
125+
"grpc.client.attempt.rcvd_total_compressed_message_size",
126+
"grpc.client.attempt.started",
127+
"grpc.client.attempt.duration",
128+
"grpc.client.call.duration");
129+
114130
static Map<InstrumentSelector, View> getAllViews() {
115131
ImmutableMap.Builder<InstrumentSelector, View> views = ImmutableMap.builder();
116132
defineView(
@@ -153,6 +169,7 @@ static Map<InstrumentSelector, View> getAllViews() {
153169
Aggregation.sum(),
154170
InstrumentType.COUNTER,
155171
"1");
172+
defineGRPCView(views);
156173
return views.build();
157174
}
158175

@@ -183,4 +200,26 @@ private static void defineView(
183200
.build();
184201
viewMap.put(selector, view);
185202
}
203+
204+
private static void defineGRPCView(ImmutableMap.Builder<InstrumentSelector, View> viewMap) {
205+
for (String metric : BuiltInMetricsConstant.GRPC_METRICS_TO_ENABLE) {
206+
InstrumentSelector selector =
207+
InstrumentSelector.builder()
208+
.setName(metric)
209+
.setMeterName(BuiltInMetricsConstant.GRPC_METER_NAME)
210+
.build();
211+
Set<String> attributesFilter =
212+
BuiltInMetricsConstant.COMMON_ATTRIBUTES.stream()
213+
.map(AttributeKey::getKey)
214+
.collect(Collectors.toSet());
215+
attributesFilter.addAll(BuiltInMetricsConstant.GRPC_LB_RLS_ATTRIBUTES);
216+
217+
View view =
218+
View.builder()
219+
.setName(BuiltInMetricsConstant.METER_NAME + '/' + metric.replace(".", "/"))
220+
.setAttributeFilter(attributesFilter)
221+
.build();
222+
viewMap.put(selector, view);
223+
}
224+
}
186225
}

0 commit comments

Comments
 (0)