Skip to content

Commit

Permalink
fix: add a UUID in the task value (#1430)
Browse files Browse the repository at this point in the history
The jvmName when calling from cloud function will always be 1@localhost. Add a UUID in the default task value string so we won't have multiple tasks writing to the same stream.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/java-bigtable/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> ☕️

If you write sample code, please follow the [samples format](
https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
  • Loading branch information
mutianf authored Sep 27, 2022
1 parent e6788b0 commit 3bfc7bc
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -168,7 +169,7 @@ static String getDefaultTaskValue() {
// Generate a random number and use the same format "random_number@hostname".
return "java-" + new SecureRandom().nextInt() + "@" + hostname;
}
return "java-" + jvmName;
return "java-" + UUID.randomUUID() + jvmName;
}

private static MetricKind createMetricKind(Type type) {
Expand Down

0 comments on commit 3bfc7bc

Please sign in to comment.