[Feature] Integrate SQL/PPL with query-insights plugin - #5636
[Feature] Integrate SQL/PPL with query-insights plugin#5636KishoreKicha14 wants to merge 1 commit into
Conversation
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit c50c128.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
PR Reviewer Guide 🔍(Review updated until commit c50c128)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to c50c128 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit dcd396f
Suggestions up to commit c50c128
Suggestions up to commit 4985f3d
Suggestions up to commit b100945
Suggestions up to commit 134b552
|
705b115 to
8c958a8
Compare
|
Persistent review updated to latest commit 8c958a8 |
8c958a8 to
1e86aa4
Compare
|
Persistent review updated to latest commit 1e86aa4 |
1e86aa4 to
70cb9db
Compare
|
Persistent review updated to latest commit 70cb9db |
|
Persistent review updated to latest commit a38aeb9 |
42927c2 to
78e60a8
Compare
|
Persistent review updated to latest commit c3e375a |
a38aeb9 to
42927c2
Compare
|
Persistent review updated to latest commit 134b552 |
ansjcy
left a comment
There was a problem hiding this comment.
I need to take a closer look into the core logistics but please make sure you format this PR before submitting.
| Optional<Throwable> calciteFailure) { | ||
| try { | ||
| executePlan(analyze(plan, queryType), PlanContext.emptyPlanContext(), listener); | ||
| org.opensearch.sql.common.utils.QueryPhaseTracker tracker = |
There was a problem hiding this comment.
please do proper import, don't use org.opensearch.sql.common.utils.QueryPhaseTracker..
| // This happens if Calcite fell back to V2 due to some issue, and then V2 also failed. | ||
| // Prefer the Calcite error. | ||
| // https://github.com/opensearch-project/sql/issues/5060 | ||
| // Calcite fell back to V2 which also failed — prefer Calcite error (#5060) |
134b552 to
b100945
Compare
|
Persistent review updated to latest commit b100945 |
b100945 to
4985f3d
Compare
|
Persistent review updated to latest commit 4985f3d |
…racking headers (x-query-source, x-original-query, x-query-execution-id, x-query-phases) to SQL and PPL execution paths so query-insights can identify and track SQL/PPL queries separately from DSL queries. - Add QueryPhaseTracker for tracking parse/analyze/plan phases - Tag thread context with SQL/PPL source headers in transport actions - Add writePhaseHeader() to Calcite execution path for PPL queries - Register all tracking headers as task headers for propagation Signed-off-by: Kishore Kumaar Natarajan <kkumaarn@amazon.com>
4985f3d to
c50c128
Compare
|
Persistent review updated to latest commit c50c128 |
c50c128 to
dcd396f
Compare
|
Persistent review updated to latest commit dcd396f |
dcd396f to
c50c128
Compare
|
Persistent review updated to latest commit c50c128 |
|
Instead of injecting four new request headers, can you add the parent id to the DSL search tasks created by sql/ppl? Then every normal DSL search task will have a reference back to its originating sql/ppl query. Query Insights can simply look up whatever info it needs, like the original request body. The gap right now is that not all DSL search tasks carry the parent PPL/SQL id. PPL v2 was instrumented recently in #5628 ( |
| () -> { | ||
| try { | ||
| QueryPhaseTracker tracker = QueryPhaseTracker.startOrRestore(); | ||
| tracker.beginPhase("analyze"); |
There was a problem hiding this comment.
Is it better to add these phase markers here instead of part of executeStage?
Can possibly rename StageErrorHandler if it's not broad enough to cover all stage-covering monitoring. Same thing with possibly merging the whole queryphasetracker into what we're already using to define these phases.
There was a problem hiding this comment.
did you mean to put this ai review folder in the project root
| PPLQueryRequest transformedRequest = transportRequest.toPPLQueryRequest(); | ||
|
|
||
| // Tag the thread context so query-insights can identify this as a PPL-derived query. | ||
| org.opensearch.common.util.concurrent.ThreadContext threadContext = |
There was a problem hiding this comment.
are these headers correctly getting propagated after a complex thread pool handoff?
That pr is mostly focused on v3, not sure where v2 is from. But other than that, I like this proposal, we should be roughly aligning to the existing stage tracking and thread propagation we already have as part of complex/background thread handoff. Particularly because historically thread propagation is a pain to modify and guard on edge cases, I'd be very in favor of a single component that owns "create an instrumented thread context that runs $LAMBDA and emits the right metrics to the right places." |
Description
Propagate SQL/PPL query metadata to OpenSearch's query-insights plugin so that DSL queries generated by the SQL engine are identifiable and traceable back to their originating SQL/PPL statement.
Changes:
Related Issues
Resolves #5677
Check List
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.