Closed atshaw43 closed 1 year ago
Some example functionality
package main
import (
"context"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
xrayLambda "github.com/aws/aws-xray-sdk-go/lambda"
"github.com/aws/aws-xray-sdk-go/xray"
)
func HandleRequest(ctx context.Context, event events.SQSEvent) (string, error) {
var toSample = false
for _, message := range event.Records {
if xrayLambda.IsSampled(message) {
toSample = true
}
}
if toSample {
ctx, _ = xray.BeginSubsegment(ctx, "test-lambda-1")
} else {
ctx, _ = xray.BeginSubsegmentWithoutSampling(ctx, "test-lambda-2")
}
xray.GetSegment(ctx).Close(nil)
return "Done", nil
}
func main() {
lambda.Start(HandleRequest)
}
}
Hmm seems the Lambda test case added is failing, the CI failures may not just be related to concurrency issues: https://github.com/aws/aws-xray-sdk-go/actions/runs/3341004880/jobs/5532097421#step:4:157
Issue #, if available:
Description of changes: Allow customer to override the sampling decision on subsegments.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.