fix(sdk-trace-web): propagate optimised flag in getElementXPath recursion#6335
Merged
pichlermarc merged 4 commits intoopen-telemetry:mainfrom Feb 23, 2026
Merged
Conversation
Pass the optimised flag through recursive getElementXPath calls so ancestor ids are used consistently, and add a regression test for it. Fixes open-telemetry#6323.
cjihrig
reviewed
Jan 24, 2026
- Use assert.ok() instead of if/throw for body check - Remove try/finally pattern, use direct cleanup at end of test - Use document.body directly to avoid TypeScript null checks Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 task
overbalance
reviewed
Jan 26, 2026
Member
|
@akkupratap323, are you still working on this? If yes, please address the remaining comments so we can proceed. 🙂 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6335 +/- ##
==========================================
+ Coverage 95.58% 95.68% +0.09%
==========================================
Files 314 364 +50
Lines 9590 11775 +2185
Branches 2221 2742 +521
==========================================
+ Hits 9167 11267 +2100
- Misses 423 508 +85
🚀 New features to boost your workflow:
|
optimised flag in getElementXPath recursion
pichlermarc
approved these changes
Feb 23, 2026
This was referenced Feb 23, 2026
Contributor
|
Thank you for your contribution @akkupratap323! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
optimisedflag when recursing ingetElementXPathidvalues to shorten XPath results when availableBackground
getElementXPathcurrently forcesoptimised=falsein the recursive call.That discards ancestor IDs and yields verbose XPaths such as
//html/body/divinstead of the expected
//*[@id="body-id"]/div.Fix
Propagate the
optimisedargument through recursion so the algorithm canshort-circuit to an ancestor
idas intended.Verification
Issue
Fixes #6323