16
16
17
17
package com .google .cloud .spanner ;
18
18
19
+ import static com .google .cloud .spanner .BuiltInMetricsConstant .CLIENT_HASH_KEY ;
19
20
import static com .google .cloud .spanner .BuiltInMetricsConstant .CLIENT_NAME_KEY ;
20
21
import static com .google .cloud .spanner .BuiltInMetricsConstant .CLIENT_UID_KEY ;
21
22
import static com .google .cloud .spanner .BuiltInMetricsConstant .DATABASE_KEY ;
@@ -76,6 +77,8 @@ public class SpannerCloudMonitoringExporterTest {
76
77
private static final String locationId = "global" ;
77
78
private static final String databaseId = "fake-database" ;
78
79
private static final String clientName = "spanner-java" ;
80
+
81
+ private static final String clientHash = "spanner-test" ;
79
82
private static final String instanceConfigId = "fake-instance-config-id" ;
80
83
81
84
@ Rule public final MockitoRule mockitoRule = MockitoJUnit .rule ();
@@ -101,6 +104,7 @@ public void setUp() {
101
104
.put (INSTANCE_CONFIG_ID_KEY , instanceConfigId )
102
105
.put (DATABASE_KEY , databaseId )
103
106
.put (CLIENT_NAME_KEY , clientName )
107
+ .put (CLIENT_HASH_KEY , clientHash )
104
108
.put (String .valueOf (DIRECT_PATH_ENABLED_KEY ), true )
105
109
.put (String .valueOf (DIRECT_PATH_USED_KEY ), true )
106
110
.build ();
@@ -153,9 +157,10 @@ public void testExportingSumData() {
153
157
PROJECT_ID_KEY .getKey (), projectId ,
154
158
INSTANCE_ID_KEY .getKey (), instanceId ,
155
159
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 );
157
162
158
- assertThat (timeSeries .getResource ().getLabelsMap ()).hasSize (4 );
163
+ assertThat (timeSeries .getResource ().getLabelsMap ()).hasSize (5 );
159
164
160
165
assertThat (timeSeries .getMetric ().getLabelsMap ())
161
166
.containsExactly (
@@ -218,13 +223,14 @@ public void testExportingHistogramData() {
218
223
219
224
TimeSeries timeSeries = request .getTimeSeriesList ().get (0 );
220
225
221
- assertThat (timeSeries .getResource ().getLabelsMap ()).hasSize (4 );
226
+ assertThat (timeSeries .getResource ().getLabelsMap ()).hasSize (5 );
222
227
assertThat (timeSeries .getResource ().getLabelsMap ())
223
228
.containsExactly (
224
229
PROJECT_ID_KEY .getKey (), projectId ,
225
230
INSTANCE_ID_KEY .getKey (), instanceId ,
226
231
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 );
228
234
229
235
assertThat (timeSeries .getMetric ().getLabelsMap ()).hasSize (4 );
230
236
assertThat (timeSeries .getMetric ().getLabelsMap ())
@@ -296,13 +302,14 @@ public void testExportingSumDataInBatches() {
296
302
timeSeries = secondRequest .getTimeSeriesList ().get (i - 200 );
297
303
}
298
304
299
- assertThat (timeSeries .getResource ().getLabelsMap ()).hasSize (4 );
305
+ assertThat (timeSeries .getResource ().getLabelsMap ()).hasSize (5 );
300
306
assertThat (timeSeries .getResource ().getLabelsMap ())
301
307
.containsExactly (
302
308
PROJECT_ID_KEY .getKey (), projectId ,
303
309
INSTANCE_ID_KEY .getKey (), instanceId ,
304
310
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 );
306
313
307
314
assertThat (timeSeries .getMetric ().getLabelsMap ()).hasSize (5 );
308
315
assertThat (timeSeries .getMetric ().getLabelsMap ())
0 commit comments