selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[🚀 Feature]: `TracedCommandExecutor` better span name

Open felixscheinost opened this issue 1 year ago • 3 comments

Feature and motivation

We are trying to use OTel tracing to find bottlenecks in the integration tests in our codebase.

We are looking for example for inefficient traversal off large DOM structures, which could be improved using better XPath queries.

Currently all spans generated by Selenium look the same, they all have "command" as the span name. (https://github.com/SeleniumHQ/selenium/blob/17d927b596898f666b0377ab40afe05434c6d8df/java/src/org/openqa/selenium/remote/TracedCommandExecutor.java#L38) You have to click on them (in most GUIs) to view the command name in the span attributes which isn't very nice to quickly go through a big trace to find inefficiencies.

The guide says:

The span name concisely identifies the work represented by the Span, for example, an RPC method name, a function name, or the name of a subtask or stage within a larger computation. The span name SHOULD be the most general string that identifies a (statistically) interesting class of Spans, rather than individual Span instances while still being human-readable. That is, "get_user" is a reasonable name, while "get_user/314159", where "314159" is a user ID, is not a good name due to its high cardinality. Generality SHOULD be prioritized over human-readability.

My read is that if following this guide making the span name more special would be a good idea. E.g. "screenshot", "setCurrentWindowSize", "findElement", ...

Usage example

Make spans more readable. Instead of having:

  • command
  • command
  • command
  • command

I imagine

  • open
  • findElement
  • executeScript
  • screenshot

as an example.

felixscheinost avatar May 03 '24 14:05 felixscheinost

@felixscheinost, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

github-actions[bot] avatar May 03 '24 14:05 github-actions[bot]

Hello! Thank you for details. I agree with your suggestion here and I am glad that will help you use the OTel bit in Selenium better. Would be open to sending a PR? We are more than happy to receive contributions on this front! :)

pujagani avatar May 06 '24 04:05 pujagani

This issue is looking for contributors.

Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested.

github-actions[bot] avatar May 06 '24 04:05 github-actions[bot]