Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(spanner): Add changes in Spanner executor for testing end to end tracing #10450

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

nareshz
Copy link

@nareshz nareshz commented Jun 27, 2024

This PR adds changes in spanner executor code required for testing end to end tracing feature.

@nareshz nareshz requested review from a team as code owners June 27, 2024 09:51
@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label Jun 27, 2024
@@ -110,11 +140,20 @@ func (h *CloudStreamHandler) startHandlingRequest(ctx context.Context, req *exec
}

// Get a new action handler based on the input action.
actionHandler, err := h.newActionHandler(inputAction, outcomeSender)
actionType, actionHandler, err := h.newActionHandler(inputAction, outcomeSender)
Copy link
Contributor

Choose a reason for hiding this comment

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

actionType can be derived directly from inputAction. Passing it from newActionHandler is redundant and is hard to maintain.

My suggestion would be,
Create a new function and use it where required.

func getActionType(inputAction *executorpb.SpannerAction) string {
    // GET THE ACTION TYPE
    action := fmt.Sprintf("%T", inputAction.GetAction())
   // Here action will have output as `*executorpb.SpannerAction_Query`. Apply string processing to convert into required format
}

// newActionHandler instantiates an actionHandler for executing the given action.
func (h *CloudStreamHandler) newActionHandler(action *executorpb.SpannerAction, outcomeSender *outputstream.OutcomeSender) (cloudActionHandler, error) {
func (h *CloudStreamHandler) newActionHandler(action *executorpb.SpannerAction, outcomeSender *outputstream.OutcomeSender) (string, cloudActionHandler, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets not make this change and instead use the suggestion above.

return h.OutcomeSender.FinishWithError(err)
}
// Create a trace client to read the traces from Cloud Trace.
traceClient, err := trace.NewClient(ctx, h.TraceClientOptions...)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the traceClient is independent of the type of action and can be initialized just once at the beginning of the Execute() method - here.
Remove it from StartBatchTxnHandler and StartTxnHandler.

FlowContext *ExecutionFlowContext
OutcomeSender *outputstream.OutcomeSender
Options []option.ClientOption
TraceClientOptions []option.ClientOption
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@harshachinta harshachinta left a comment

Choose a reason for hiding this comment

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

Reviewed couple of files and added comments. Will take a look at the remaining files after these changes are incorporated.

@harshachinta harshachinta changed the title feat(Spanner): Add changes in Spanner executor for testing end to end tracing chore(spanner): Add changes in Spanner executor for testing end to end tracing Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants