-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: main
Are you sure you want to change the base?
Conversation
…into systest-otel-context
…into systest-changes
…into e2e-trace-optin
…into systest-changes
…into systest-changes
@@ -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) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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...) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed and can be removed with https://github.com/googleapis/google-cloud-go/pull/10450/files#r1665520383
There was a problem hiding this 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.
…into systest-changes
This PR adds changes in spanner executor code required for testing end to end tracing feature.