Skip to content

Commit

Permalink
provide a valid xray trace ID for the invocation (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikschubert authored Jan 25, 2023
1 parent 5a24e7e commit f03a1f0
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions cmd/localstack/custom_interop.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ func NewCustomInteropServer(lsOpts *LsOpts, delegate rapidcore.InteropServer, lo
}

go func() {
receivedPayload := string(bytess)
log.WithField("receivedPayload", receivedPayload).Debugln("hi")
err = json.Unmarshal(bytess, &invokeR)
if err != nil {
log.Error(err)
Expand All @@ -93,13 +91,25 @@ func NewCustomInteropServer(lsOpts *LsOpts, delegate rapidcore.InteropServer, lo
invokeStart := time.Now()
err = server.Invoke(invokeResp, &interop.Invoke{
ID: invokeR.InvokeId,
TraceID: "TraceID", // r.Header.Get("X-Amzn-Trace-Id"),
LambdaSegmentID: "LambdaSegmentID", // r.Header.Get("X-Amzn-Segment-Id"),
InvokedFunctionArn: invokeR.InvokedFunctionArn,
Payload: strings.NewReader(invokeR.Payload), // r.Body,
CorrelationID: "invokeCorrelationID",
NeedDebugLogs: true,
InvokedFunctionArn: invokeR.InvokedFunctionArn,
//DeadlineNs:
CorrelationID: "invokeCorrelationID",
// TODO: should we use the env _X_AMZN_TRACE_ID here or get the value from the request headers from the direct invoke?
// for now we just set a "real" static value
TraceID: "Root=1-53cfd31b-192638fa13e39d2c2bcea001;Parent=365fb4b15f2e3987;Sampled=0", // r.Header.Get("X-Amzn-Trace-Id"),
//TraceID: GetEnvOrDie("_X_AMZN_TRACE_ID"), // r.Header.Get("X-Amzn-Trace-Id"),
// TODO: set correct segment ID from request
//LambdaSegmentID: "LambdaSegmentID", // r.Header.Get("X-Amzn-Segment-Id"),
//CognitoIdentityID: "",
//CognitoIdentityPoolID: "",
//DeadlineNs: "",
//ClientContext: "",
//ContentType: "",
//ReservationToken: "",
//VersionID: "",
//InvokeReceivedTime: 0,
//ResyncState: interop.Resync{},
})
timeout := int(server.delegate.GetInvokeTimeout().Seconds())
isErr := false
Expand Down

0 comments on commit f03a1f0

Please sign in to comment.