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

Respect setParent calls for noop subsegments. #215

Merged

Conversation

anuraaga
Copy link
Contributor

Fixes #213

I mistook that the parent and parent segment are the same. The API is crufty in setting the parent after construction, even though it's a constant, that could be another improvement for a major version.

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

public void testLeakedSubsegmentsAreCleanedBetweenInvocations() {

@SetEnvironmentVariable(key = "_X_AMZN_TRACE_ID", value = TRACE_HEADER_2)
void testNotSampledSetsParentToSubsegment() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the new test, the rest are refactoring to replace powermock with junit5 extension

Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely a "side-by-side" instead of inline type of review :)

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.

Just noticed your branch name and 🤣

public void testLeakedSubsegmentsAreCleanedBetweenInvocations() {

@SetEnvironmentVariable(key = "_X_AMZN_TRACE_ID", value = TRACE_HEADER_2)
void testNotSampledSetsParentToSubsegment() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely a "side-by-side" instead of inline type of review :)

@@ -59,55 +58,71 @@ public void setupAWSXRay() {
}

@Test
public void testBeginSubsegmentWithNullTraceHeaderEnvironmentVariableResultsInADummySegmentParent() {
testMockContext(TraceHeader.fromString(null), FacadeSegment.class);
void testBeginSubsegmentWithNullTraceHeaderEnvironmentVariableResultsInADummySegmentParent() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is mostly out of scope for the PR, but the name of this test isn't right. The name says we expect a Dummy (no-op) segment whereas what we test for/actually get is a facade segment.

I'm pretty sure contrary to the name of the test always using a facade segment is the behavior we want, and we can have a larger discussion if anyone on team disagrees, but for now renaming the test to avoid future confusion would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - yeah good cleanup

public void testBeginSubsegmentWithIncompleteTraceHeaderEnvironmentVariableResultsInADummySegmentParent() {
testMockContext(TraceHeader.fromString("a"), FacadeSegment.class);
@SetEnvironmentVariable(key = "_X_AMZN_TRACE_ID", value = "a")
void testBeginSubsegmentWithIncompleteTraceHeaderEnvironmentVariableResultsInADummySegmentParent() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto on renaming

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.

Subsegment cannot be found on 2.7.1 / AWS Lambda
2 participants