Conversation

mayurkale22

Supersedes #1042

Adds a sample for assigning and querying tags.

Follow-up to #576

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 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> ☕️

@mayurkale22mayurkale22 requested a review from a team as a code owner September 30, 2021 17:50
@snippet-bot

Here is the summary of changes.

You are about to add 2 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-labelproduct-auto-label bot added the api: spannerIssues related to the googleapis/java-spanner API.label Sep 30, 2021
@google-clagoogle-cla bot added the cla: yesThis human has signed the Contributor License Agreement.label Sep 30, 2021
@product-auto-labelproduct-auto-label bot added the samplesIssues that are directly related to samples.label Sep 30, 2021
databaseClient
.readWriteTransaction(Options.tag("app=concert,env=dev"))
.run(
new TransactionCallable<Void>() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could you use Java 8 lambda notation instead of an anonymous class?

.run(transaction -> {
  ...
})

// Execute query multiple times to give a better chance of being part of the TopN tables.
for (int i = 0; i < 50; i++) {
final String out = runSample(() -> TransactionWithTagSample.setRequestTag(client));
assertThat(out).contains("1 1 title 1");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long does this take to run? Could we break as soon as we reach a condition?

if (queryStatsFound) {
break;
}
Thread.sleep(5000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we reduce the sleep time here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set_transaction_tag sample is based on an outdated version of the spec. Please update it to match the current spec.

@thiagotnunes

Closing in favour of #1496

Sign up for free to join this conversation on . Already have an account? Sign in to comment
api: spannerIssues related to the googleapis/java-spanner API.cla: yesThis human has signed the Contributor License Agreement.samplesIssues that are directly related to samples.
None yet

Successfully merging this pull request may close these issues.