1616
1717package com .google .cloud .spanner ;
1818
19+ import static com .google .cloud .spanner .BuiltInMetricsConstant .CLIENT_HASH_KEY ;
1920import static com .google .cloud .spanner .BuiltInMetricsConstant .CLIENT_NAME_KEY ;
2021import static com .google .cloud .spanner .BuiltInMetricsConstant .CLIENT_UID_KEY ;
2122import static com .google .cloud .spanner .BuiltInMetricsConstant .DATABASE_KEY ;
@@ -76,6 +77,8 @@ public class SpannerCloudMonitoringExporterTest {
7677 private static final String locationId = "global" ;
7778 private static final String databaseId = "fake-database" ;
7879 private static final String clientName = "spanner-java" ;
80+
81+ private static final String clientHash = "spanner-test" ;
7982 private static final String instanceConfigId = "fake-instance-config-id" ;
8083
8184 @ Rule public final MockitoRule mockitoRule = MockitoJUnit .rule ();
@@ -101,6 +104,7 @@ public void setUp() {
101104 .put (INSTANCE_CONFIG_ID_KEY , instanceConfigId )
102105 .put (DATABASE_KEY , databaseId )
103106 .put (CLIENT_NAME_KEY , clientName )
107+ .put (CLIENT_HASH_KEY , clientHash )
104108 .put (String .valueOf (DIRECT_PATH_ENABLED_KEY ), true )
105109 .put (String .valueOf (DIRECT_PATH_USED_KEY ), true )
106110 .build ();
@@ -153,9 +157,10 @@ public void testExportingSumData() {
153157 PROJECT_ID_KEY .getKey (), projectId ,
154158 INSTANCE_ID_KEY .getKey (), instanceId ,
155159 LOCATION_ID_KEY .getKey (), locationId ,
156- INSTANCE_CONFIG_ID_KEY .getKey (), instanceConfigId );
160+ INSTANCE_CONFIG_ID_KEY .getKey (), instanceConfigId ,
161+ CLIENT_HASH_KEY .getKey (), clientHash );
157162
158- assertThat (timeSeries .getResource ().getLabelsMap ()).hasSize (4 );
163+ assertThat (timeSeries .getResource ().getLabelsMap ()).hasSize (5 );
159164
160165 assertThat (timeSeries .getMetric ().getLabelsMap ())
161166 .containsExactly (
@@ -218,13 +223,14 @@ public void testExportingHistogramData() {
218223
219224 TimeSeries timeSeries = request .getTimeSeriesList ().get (0 );
220225
221- assertThat (timeSeries .getResource ().getLabelsMap ()).hasSize (4 );
226+ assertThat (timeSeries .getResource ().getLabelsMap ()).hasSize (5 );
222227 assertThat (timeSeries .getResource ().getLabelsMap ())
223228 .containsExactly (
224229 PROJECT_ID_KEY .getKey (), projectId ,
225230 INSTANCE_ID_KEY .getKey (), instanceId ,
226231 LOCATION_ID_KEY .getKey (), locationId ,
227- INSTANCE_CONFIG_ID_KEY .getKey (), instanceConfigId );
232+ INSTANCE_CONFIG_ID_KEY .getKey (), instanceConfigId ,
233+ CLIENT_HASH_KEY .getKey (), clientHash );
228234
229235 assertThat (timeSeries .getMetric ().getLabelsMap ()).hasSize (4 );
230236 assertThat (timeSeries .getMetric ().getLabelsMap ())
@@ -296,13 +302,14 @@ public void testExportingSumDataInBatches() {
296302 timeSeries = secondRequest .getTimeSeriesList ().get (i - 200 );
297303 }
298304
299- assertThat (timeSeries .getResource ().getLabelsMap ()).hasSize (4 );
305+ assertThat (timeSeries .getResource ().getLabelsMap ()).hasSize (5 );
300306 assertThat (timeSeries .getResource ().getLabelsMap ())
301307 .containsExactly (
302308 PROJECT_ID_KEY .getKey (), projectId ,
303309 INSTANCE_ID_KEY .getKey (), instanceId ,
304310 LOCATION_ID_KEY .getKey (), locationId ,
305- INSTANCE_CONFIG_ID_KEY .getKey (), instanceConfigId );
311+ INSTANCE_CONFIG_ID_KEY .getKey (), instanceConfigId ,
312+ CLIENT_HASH_KEY .getKey (), clientHash );
306313
307314 assertThat (timeSeries .getMetric ().getLabelsMap ()).hasSize (5 );
308315 assertThat (timeSeries .getMetric ().getLabelsMap ())
0 commit comments