Skip to content

Fix Flaky Ratpack Fork Test - #622

Merged
gary-huang merged 2 commits into
masterfrom
gary/fix-ratpack-test
Dec 9, 2018
Merged

Fix Flaky Ratpack Fork Test#622
gary-huang merged 2 commits into
masterfrom
gary/fix-ratpack-test

Conversation

@gary-huang

Copy link
Copy Markdown
Contributor

Ratpack tests occasionally fail with the handler span and manually started span out of order. This will ensure that if a span is manually started inside of the handler then it will be finished after the handler span is finished, which is when the request has been responded to.

Ratpack tests occasionally fail with the handler span and manually started span out of order. This will ensure that if a span is manually started inside of the handler then it will be finished after the handler span is finished, which is when the request has been responded to.
context.onClose {
if (startSpanInHandler) {
final Scope activeScope = GlobalTracer.get().scopeManager().active()
((TraceScope) activeScope).setAsyncPropagation(false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@realark does this even do anything given the scope is closed on the next line?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not it won't. Closing the scope has the same effect as turning off async.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So ((TraceScope) activeScope).setAsyncPropagation(false) is not needed? Was this an effect of the new change in the executor instrumentation?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well it's only needed if the scope is not being closed. Since the active scope is being closed turning off async is not required.

I'm not following the instrumentation and testing approach here, but it's usually a bad idea to close a scope you didn't create. Should we be closing out the scope here, or should we let the creator of the scope handle that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The creator of the scope here is the test itself. I.e. the current active scope is the scope started by the test. I just pushed a change, perhaps that's a better approach to this test?

((TraceScope) scope).setAsyncPropagation(false)
scope.close()
context.onClose {
startedSpan.finish()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@realark is this a better way to handle the scope?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks ok to me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

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