Skip to content

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

Merged
trask merged 2 commits into
open-telemetry:mainfrom
agoallikmaa:ratpack-concurrency-fix
May 6, 2021
Merged

Fix Ratpack server context propagation and enable its concurrency test#2910
trask merged 2 commits into
open-telemetry:mainfrom
agoallikmaa:ratpack-concurrency-fix

Conversation

@agoallikmaa

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@trask trask left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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