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 36 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
665c719
Setup OTel and add tracecontext header in Spanner requests
nareshz May 17, 2024
c4c88c0
Add x-goog-spanner-end-to-end-tracing header for requests to SpanFE
nareshz May 21, 2024
167a6b3
Merge remote-tracking branch 'root/main' into e2e-trace-optin
nareshz May 21, 2024
68a0647
Merge remote-tracking branch 'root/main' into e2e-trace-optin
nareshz May 21, 2024
5a91d0f
resolve comments
nareshz May 21, 2024
8985992
enable opentelemetry
nareshz May 24, 2024
ce42792
test
nareshz May 27, 2024
7bc7ec5
Roots CA changes
nareshz May 28, 2024
c938f8d
test
nareshz May 28, 2024
aeaadb4
changes for correct trace
nareshz May 30, 2024
eb6e7ed
Merge branch 'main' of https://github.com/googleapis/google-cloud-go …
nareshz May 30, 2024
592a6de
Merge branch 'main' into e2e-trace-optin
rahul2393 Jun 5, 2024
e61838c
Merge branch 'main' of https://github.com/googleapis/google-cloud-go …
nareshz Jun 12, 2024
6e7ba8b
Merge branch 'main' of https://github.com/googleapis/google-cloud-go …
nareshz Jun 12, 2024
61aced3
Merge branch 'e2e-trace-optin' into systest-changes
nareshz Jun 12, 2024
b420890
Merge branch 'main' of https://github.com/googleapis/google-cloud-go …
nareshz Jun 27, 2024
7344e03
changes for end to end tracing feature testing in spanner executor
nareshz Jun 27, 2024
f01af3a
Merge branch 'main' of https://github.com/googleapis/google-cloud-go …
nareshz Jun 27, 2024
4ffd0aa
fix unwanted changes
nareshz Jun 27, 2024
7691d4e
minor fix
nareshz Jun 27, 2024
ae182e9
remove unnecessary log statements
nareshz Jun 27, 2024
96c9798
add spanner span check
nareshz Jun 27, 2024
787034d
add verification of spans at grpc layer
nareshz Jul 1, 2024
7e77935
Merge branch 'main' into systest-changes
harshachinta Jul 1, 2024
308066a
Merge branch 'main' of https://github.com/googleapis/google-cloud-go …
nareshz Jul 22, 2024
689fcdb
resolve comments
nareshz Aug 8, 2024
2660d43
Merge branch 'main' of https://github.com/googleapis/google-cloud-go …
nareshz Aug 8, 2024
96644a0
rename end to end tracing to server side tracing
nareshz Aug 8, 2024
2b10bf6
minor change
nareshz Aug 8, 2024
b60ef9b
Merge branch 'main' of https://github.com/googleapis/google-cloud-go …
nareshz Aug 9, 2024
031a309
Merge branch 'main' of https://github.com/googleapis/google-cloud-go …
nareshz Aug 11, 2024
37fc4dc
Merge branch 'main' of https://github.com/googleapis/google-cloud-go …
nareshz Aug 13, 2024
352072a
resolve comments
nareshz Aug 20, 2024
f32dc98
add comment for server side tracing option
nareshz Aug 20, 2024
be209c3
Merge branch 'main' of https://github.com/googleapis/google-cloud-go …
nareshz Aug 20, 2024
8f9c8a0
Merge branch 'main' of https://github.com/googleapis/google-cloud-go …
nareshz Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test
  • Loading branch information
nareshz committed May 28, 2024
commit c938f8d83b12e97d3f786bb2509e938c31c56636
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func getCloudTraceClientOptions() ([]option.ClientOption, error) {
log.Printf("serviceKeyFile contents: %v\n", fileContents)

var traceClientOpts []option.ClientOption
traceClientOpts = append(traceClientOpts, option.WithEndpoint("cloudtrace.googleapis.com:443"))
traceClientOpts = append(traceClientOpts, option.WithEndpoint("staging-cloudtrace.sandbox.googleapis.com:443"))

// perRPCCredentials, err := oauth.NewJWTAccessFromKey(cloudSystestCredentialsJSON)
// if err != nil {
Expand Down Expand Up @@ -160,6 +160,7 @@ func (h *CloudStreamHandler) startHandlingRequest(ctx context.Context, req *exec
if err != nil {
return outcomeSender.FinishWithError(err)
}
actionHandlerType := actionHandlerType(inputAction)

// Setup trace context propagation.
tc := propagation.TraceContext{}
Expand All @@ -183,16 +184,16 @@ func (h *CloudStreamHandler) startHandlingRequest(ctx context.Context, req *exec
}
tp := sdktrace.NewTracerProvider(
sdktrace.WithBatcher(traceExporter),
sdktrace.WithSampler(sdktrace.AlwaysSample()),
sdktrace.WithSampler(sdktrace.TraceIDRatioBased(0.1)),
)
defer func() { _ = tp.Shutdown(ctx) }()

otel.SetTracerProvider(tp)

tracer := tp.Tracer("nareshz-test.com/trace")
tracer := tp.Tracer("nareshz-systest.com/trace")

// Create a span for the systest action.
ctx, span := tracer.Start(ctx, "systestactiontrace")
ctx, span := tracer.Start(ctx, fmt.Sprintf("systestaction_%v", actionHandlerType))
defer span.End()

// Create a channel to receive the error from the goroutine.
Expand Down Expand Up @@ -222,6 +223,44 @@ func (h *CloudStreamHandler) startHandlingRequest(ctx context.Context, req *exec
}
}

// newActionHandler instantiates an actionHandler for executing the given action.
func actionHandlerType(action *executorpb.SpannerAction) string {
switch action.GetAction().(type) {
case *executorpb.SpannerAction_Start:
return "SpannerAction_Start"
case *executorpb.SpannerAction_Finish:
return "SpannerAction_Finish"
case *executorpb.SpannerAction_Admin:
return "SpannerAction_Admin"
case *executorpb.SpannerAction_Read:
return "SpannerAction_Read"
case *executorpb.SpannerAction_Query:
return "SpannerAction_Query"
case *executorpb.SpannerAction_Mutation:
return "SpannerAction_Mutation"
case *executorpb.SpannerAction_Write:
return "SpannerAction_Write"
case *executorpb.SpannerAction_Dml:
return "SpannerAction_Dml"
case *executorpb.SpannerAction_StartBatchTxn:
return "SpannerAction_StartBatchTxn"
case *executorpb.SpannerAction_GenerateDbPartitionsRead:
return "SpannerAction_GenerateDbPartitionsRead"
case *executorpb.SpannerAction_GenerateDbPartitionsQuery:
return "SpannerAction_GenerateDbPartitionsQuery"
case *executorpb.SpannerAction_ExecutePartition:
return "SpannerAction_ExecutePartition"
case *executorpb.SpannerAction_PartitionedUpdate:
return "SpannerAction_PartitionedUpdate"
case *executorpb.SpannerAction_CloseBatchTxn:
return "SpannerAction_CloseBatchTxn"
case *executorpb.SpannerAction_BatchDml:
return "SpannerAction_BatchDml"
default:
return "SpannerAction_default"
}
}

// newActionHandler instantiates an actionHandler for executing the given action.
func (h *CloudStreamHandler) newActionHandler(action *executorpb.SpannerAction, outcomeSender *outputstream.OutcomeSender) (cloudActionHandler, error) {
if action.DatabasePath != "" {
Expand Down