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

Disabling sdk feature #219

Merged
merged 41 commits into from
Jun 1, 2020
Merged

Disabling sdk feature #219

merged 41 commits into from
Jun 1, 2020

Conversation

bhautikpip
Copy link
Contributor

Issue #, if available:

Description of changes:

Added environment variable support to disable SDK feature.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@bhautikpip bhautikpip changed the title Disable sdk Disabling sdk feature Apr 12, 2020
Copy link
Contributor

@willarmiros willarmiros left a comment

Choose a reason for hiding this comment

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

I think some fields need to be populated in the segments even when disabled. Either that or you need to add the disabled check to more methods of segment.

xray/segment.go Show resolved Hide resolved
xray/segment.go Outdated Show resolved Hide resolved
@dcu
Copy link

dcu commented Apr 14, 2020

for anyone interested in testing this change, add this line to your go.mod:

replace github.com/aws/aws-xray-sdk-go => github.com/bhautikpip/aws-xray-sdk-go Disable-SDK

and then run:

go mod tidy

Copy link
Contributor

@willarmiros willarmiros left a comment

Choose a reason for hiding this comment

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

LGTM

xray/segment.go Show resolved Hide resolved
xray/segment.go Outdated
@@ -61,6 +62,13 @@ func BeginSegment(ctx context.Context, name string) (context.Context, *Segment)
}

func BeginSegmentWithSampling(ctx context.Context, name string, r *http.Request, traceHeader *header.Header) (context.Context, *Segment) {
// If SDK is disabled then return with an empty segment
disableKey := os.Getenv("AWS_XRAY_SDK_DISABLED")
Copy link
Contributor

@anuraaga anuraaga May 19, 2020

Choose a reason for hiding this comment

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

Does it make sense to put this in the Config in config.go? If not, at least we should extract a function for this instead of copying it everywhere.

Copy link
Contributor Author

@bhautikpip bhautikpip May 19, 2020

Choose a reason for hiding this comment

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

That's a fair point. We can extract a function instead of writing this logic everywhere. Also, as per my understanding even if we put this in config.go we still have to put this logic in the entry-point of the publicly exposed methods.

@bhautikpip bhautikpip requested a review from anuraaga May 30, 2020 19:12
Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

Some nits and golint otherwise LGTM

xray/segment.go Outdated
@@ -61,6 +62,13 @@ func BeginSegment(ctx context.Context, name string) (context.Context, *Segment)
}

func BeginSegmentWithSampling(ctx context.Context, name string, r *http.Request, traceHeader *header.Header) (context.Context, *Segment) {
// If SDK is disabled then return with an empty segment
sdkDisable := Disabled()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to have this local variable instead of just if Disabled()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makse sense! will modify it

xray/segment.go Show resolved Hide resolved
xray/segment.go Outdated
@@ -271,8 +286,23 @@ func NewSegmentFromHeader(ctx context.Context, name string, r *http.Request, h *
return con, seg
}

// Check if SDK is disabled
func Disabled() bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Especially if removing the local variable, probably good to name this func SdkDisabled()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right.

@bhautikpip bhautikpip requested a review from anuraaga June 1, 2020 02:16
@bhautikpip bhautikpip merged commit 68c06a5 into aws:master Jun 1, 2020
@cynicaljoy cynicaljoy mentioned this pull request Jul 30, 2020
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.

4 participants