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

Oversampling Mitigation #381

Merged
merged 15 commits into from
Nov 1, 2022
Merged

Oversampling Mitigation #381

merged 15 commits into from
Nov 1, 2022

Conversation

atshaw43
Copy link
Contributor

@atshaw43 atshaw43 commented Oct 13, 2022

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.

@atshaw43 atshaw43 requested a review from a team as a code owner October 13, 2022 19:31
@atshaw43
Copy link
Contributor Author

atshaw43 commented Oct 27, 2022

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)
   }
}

@willarmiros
Copy link
Contributor

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

Copy link
Contributor

@wangzlei wangzlei left a comment

Choose a reason for hiding this comment

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

LGTM

@atshaw43 atshaw43 merged commit c67765e into aws:master Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants