Skip to content

feat(spanner): add option for auto-tagging transactions#13214

Open
sakthivelmanii wants to merge 1 commit into
mainfrom
feat-spanner-auto-tagging
Open

feat(spanner): add option for auto-tagging transactions#13214
sakthivelmanii wants to merge 1 commit into
mainfrom
feat-spanner-auto-tagging

Conversation

@sakthivelmanii
Copy link
Copy Markdown
Contributor

@sakthivelmanii sakthivelmanii commented May 18, 2026

Adds an option that automatically adds transaction tags to all read/write transactions that do not already include an explicit transaction tag. For read-only transactions, this option automatically adds a request tag to each statement that is executed in the read-only transaction. The tag name is equal to the class name + method name of the method that started the transaction. Tags are limited to max 50 characters. If the combination of class name + method name exceeds 50 characters, then the last 50 characters are used as the tag.

This option can be enabled with SpannerOptions$Builder.enableAutoTagging() or by setting either the environment variable SPANNER_ENABLE_AUTO_TAGGING=true or the system property spanner.enable_auto_tagging=true.

@sakthivelmanii sakthivelmanii requested review from a team as code owners May 18, 2026 14:26
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an automatic tagging feature for Spanner transactions and requests, allowing the library to derive tags from the application's stack trace when they are not explicitly provided. Key changes include the addition of AutoTagHelper for stack trace analysis and updates to AbstractReadContext, SessionImpl, and SpannerOptions to support and configure this mechanism. Review feedback focuses on performance optimizations, specifically suggesting that the auto-tag be cached within the request context to avoid redundant stack trace captures and recommending the use of StackWalker for more efficient frame retrieval. Additionally, a recommendation was made to defensively copy the package list in SpannerOptions to maintain immutability.

@sakthivelmanii sakthivelmanii force-pushed the feat-spanner-auto-tagging branch 5 times, most recently from fadc3ec to a09b9ce Compare May 18, 2026 15:02
@sakthivelmanii sakthivelmanii force-pushed the feat-spanner-auto-tagging branch 9 times, most recently from f036bcd to 0ea0f9d Compare May 19, 2026 08:47
@olavloite
Copy link
Copy Markdown
Contributor

Can we update both the pull request title and add a new paragraph at the start of the pull request description? The current title and description are very technical and 'internal', instead of focusing on what's in it for a customer.

Suggestion:

feat(spanner): add option for auto-tagging transactions

Adds an option that automatically adds transaction tags to all read/write transactions that do not already include an explicit transaction tag. For read-only transactions, this option automatically adds a request tag to each statement that is executed in the read-only transaction. The tag name is equal to the class name + method name of the method that started the transaction. Tags are limited to max 50 characters. If the combination of class name + method name exceeds 50 characters, then the last 50 characters are used as the tag.

This option can be enabled with `SpannerOptions$Builder.enableAutoTagging()` or by setting either the environment variable SPANNER_ENABLE_AUTO_TAGGING=true or the system property spanner.enable_auto_tagging=true.

Copy link
Copy Markdown
Contributor

@olavloite olavloite left a comment

Choose a reason for hiding this comment

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

LGTM, but please also take a look at #13214 (comment)

@sakthivelmanii sakthivelmanii force-pushed the feat-spanner-auto-tagging branch 6 times, most recently from fcf923c to d0d400f Compare May 19, 2026 11:33
@sakthivelmanii sakthivelmanii changed the title feat(spanner): provide opt-in auto-tagging feature in client library feat(spanner): add option for auto-tagging transactions May 19, 2026
@sakthivelmanii sakthivelmanii force-pushed the feat-spanner-auto-tagging branch from d0d400f to 6c5ff36 Compare May 19, 2026 11:59
@sakthivelmanii sakthivelmanii force-pushed the feat-spanner-auto-tagging branch from 6c5ff36 to 3843bda Compare May 19, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants