Skip to content

Commit 4d7a45d

Browse files
committed
review comments
1 parent b8b4685 commit 4d7a45d

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,21 @@ Map<String, String> createClientAttributes(String projectId, String client_name)
9191
return clientAttributes;
9292
}
9393

94-
// Returns a 6-digit zero-padded all lower case hexadecimal representation
95-
// of hash of the accounting group.
96-
//
97-
// The hash utilizes the 10 most significant bits of the value returned by
98-
// `Hashing.goodFastHash(64).hashBytes()`, so effectively the returned values are
99-
// uniformly distributed in the range [000000, 0003ff].
100-
//
101-
// The primary purpose of this function is to generate a hash value for the
102-
// `client_hash` resource label using `client_uid` metric field.
103-
//
104-
// The range of values is chosen to be small enough to keep the cardinality of
105-
// the Resource targets under control.
106-
//
107-
// Note: If at later time the range needs to be increased, it can be done by
108-
// increasing the value of `kPrefixLength` to up to 24 bits without changing
109-
// the format of the returned value.
94+
/**
95+
* Generates a 6-digit zero-padded all lower case hexadecimal representation of hash of the
96+
* accounting group. The hash utilizes the 10 most significant bits of the value returned by
97+
* `Hashing.goodFastHash(64).hashBytes()`, so effectively the returned values are uniformly
98+
* distributed in the range [000000, 0003ff].
99+
*
100+
* <p>The primary purpose of this function is to generate a hash value for the `client_hash`
101+
* resource label using `client_uid` metric field. The range of values is chosen to be small
102+
* enough to keep the cardinality of the Resource targets under control. Note: If at later time
103+
* the range needs to be increased, it can be done by increasing the value of `kPrefixLength` to
104+
* up to 24 bits without changing the format of the returned value.
105+
*
106+
* @return Returns a 6-digit zero-padded all lower case hexadecimal representation of hash of the
107+
* accounting group.
108+
*/
110109
static String generateClientHash(String clientUid) {
111110
if (clientUid == null) {
112111
return "000000";

google-cloud-spanner/src/test/java/com/google/cloud/spanner/BuiltInOpenTelemetryMetricsProviderTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
package com.google.cloud.spanner;
1818

19-
import static com.google.common.truth.Truth.assertThat;
19+
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertTrue;
2021

2122
import org.junit.Test;
2223
import org.junit.runner.RunWith;
@@ -57,10 +58,9 @@ public void testGenerateClientHashWithSpecialCharacters() {
5758

5859
private void verifyHash(String hash) {
5960
// Check if the hash length is 6
60-
assertThat(hash.length()).isEqualTo(6);
61+
assertEquals(hash.length(), 6);
6162
// Check if the hash is in the range [000000, 0003ff]
6263
long hashValue = Long.parseLong(hash, 16); // Convert hash from hex to decimal
63-
assertThat(hashValue).isAtLeast(0);
64-
assertThat(hashValue).isAtMost(0x3FF);
64+
assertTrue(hashValue >= 0 && hashValue <= 0x3FF);
6565
}
6666
}

0 commit comments

Comments
 (0)