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

Fix Ratpack server context propagation and enable its concurrency test #2910

Merged
merged 2 commits into from May 6, 2021

Conversation

agoallikmaa
Copy link
Contributor

Fixes #2648

  • Use context from Netty channel attributes as the parent context for ratpack.handler as executor instrumentation does not work correctly for it.
  • Disable context propagation to Ratpack runnables and callables as the context they carry is not only unused, but also incorrect. As these are anonymous classes and created inside different classes, checking for exact classname does not work, so disabled it for the whole package.
  • To do the above, made classname checking use the original task instead of wrapped task for anonymous classes.
  • Enabled concurrency tests for Ratpack server.

Runnable newTask = RunnableWrapper.wrapIfNeeded(task);
if (ExecutorInstrumentationUtils.shouldAttachStateToTask(newTask)) {
if (ExecutorInstrumentationUtils.shouldAttachStateToTask(task)) {
Runnable newTask = RunnableWrapper.wrapIfNeeded(task);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could drop newTask and just assign to task.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

nice

Comment on lines +27 to +29
// Must use context from channel, as executor instrumentation is not accurate - Ratpack
// internally queues events and then drains them in batches, causing executor instrumentation to
// attach the same context to a batch of events from different requests.
Copy link
Member

Choose a reason for hiding this comment

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

👍

Comment on lines +96 to +100
// Context is passed through Netty channels in Ratpack as executor instrumentation is
// not suitable. As the context that would be propagated via executor would be
// incorrect, skip the propagation. Not checking for concrete class names as this covers
// anonymous classes from ratpack.exec.internal.DefaultExecution and
// ratpack.exec.internal.DefaultExecController.
Copy link
Member

Choose a reason for hiding this comment

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

👍

@trask trask merged commit a568daa into open-telemetry:main May 6, 2021
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.

Fix ratpack context propagation
3 participants