Skip to content

Wrap async search action logic in a new trace context#88937

Merged
pugnascotia merged 2 commits intoelastic:mainfrom
pugnascotia:use-more-tracing-contexts-part2
Aug 2, 2022
Merged

Wrap async search action logic in a new trace context#88937
pugnascotia merged 2 commits intoelastic:mainfrom
pugnascotia:use-more-tracing-contexts-part2

Conversation

@pugnascotia
Copy link
Copy Markdown
Contributor

Part of #84369. Split out from #88443. This PR wraps parts logic in
TransportSubmitAsyncSearchAction in a new tracing context. This is
necessary so that a tracing implementation can use the thread context
to propagate tracing headers, but without the code attempting to set the
same key twice in the thread context, which is illegal.

@pugnascotia pugnascotia added :Search/Search Search-related issues that do not fall into other categories >refactoring v8.5.0 labels Jul 29, 2022
@pugnascotia pugnascotia requested a review from javanna July 29, 2022 10:59
@elasticsearchmachine elasticsearchmachine added the Team:Search Meta label for search team label Jul 29, 2022
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-search (Team:Search)

@pugnascotia
Copy link
Copy Markdown
Contributor Author

Packaging test failure is unrelated.

Copy link
Copy Markdown
Contributor

@romseygeek romseygeek left a comment

Choose a reason for hiding this comment

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

LGTM

@pugnascotia pugnascotia merged commit 577c1c9 into elastic:main Aug 2, 2022
@pugnascotia pugnascotia deleted the use-more-tracing-contexts-part2 branch August 2, 2022 12:45
);
} finally {
submitListener.onResponse(searchResponse);
try (var ignored = threadContext.newTraceContext()) {
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.

Is this needed because we are registering a new task in the next line, which will stay alive once the submit action has returned a response? Is there a way to possibly do this automatically when needed? I can see how this is going to be forgotten in other places or possibly there are already places where the same change is needed which we are not aware of yet?

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.

Almost all uses of task registration happen via registerAndExecute, which handles the thread content stuff automatically. I've checked all the other places which manage tasks without registerAndExecute to make sure they're doing the right thing.

I haven't yet come up with an alternative approach unfortunately. Detecting these cases is straightforward at least, because if you don't start a new context, you get an exception!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>refactoring :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team v8.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants