Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Query Tracing #42

Closed
Daniel-Boll opened this issue Sep 27, 2024 · 3 comments · Fixed by #43
Closed

Add Support for Query Tracing #42

Daniel-Boll opened this issue Sep 27, 2024 · 3 comments · Fixed by #43
Assignees
Labels
enhancement New feature or request

Comments

@Daniel-Boll
Copy link
Owner

Currently, the driver does not provide a straightforward way to retrieve tracing information alongside the query results.

Desired API:

To make query tracing accessible, I propose adding a new method execute_with_tracing to the session object. This method will execute a query and return both the result and the tracing information without affecting the existing API.

Example Usage:

let { result, tracing } = await session.execute_with_tracing("SELECT * FROM my_table WHERE id = ?", [id]);

Proposed Changes in the Rust Wrapper:

In the Rust layer of the driver, we need to modify the query execution to enable tracing and return the tracing details. Here's how the changes might look:

// Create a new query from the JavaScript query string
let mut query = Query::new(js_query);

// Enable tracing on the query
query.set_tracing(true);

// Execute the query with the provided parameters
let query_result = self.session.execute(query, parameters);

if let Some(tracing_id) = query_result.tracing_id {
  let tracing_info = session.get_tracing_info(&tracing_id).await?;
}

By calling query.set_tracing(true);, we enable the collection of tracing information for that specific query. The execution method will then need to be updated to return both the result and the tracing data.

Benefits:

  • Non-Breaking Change: Adding a new method preserves backward compatibility, ensuring existing codebases remain unaffected.
  • Enhanced Debugging: Access to tracing information aids in diagnosing performance issues and understanding query execution paths.
  • User Opt-In: Developers can choose when to enable tracing, avoiding unnecessary overhead on queries where tracing is not needed.

Conclusion:

Implementing this feature would greatly enhance the debugging capabilities of the ScyllaDB JavaScript driver without disrupting existing functionalities.

@Daniel-Boll Daniel-Boll added the enhancement New feature or request label Sep 27, 2024
@Daniel-Boll Daniel-Boll self-assigned this Sep 27, 2024
@danielhe4rt
Copy link
Collaborator

About the paging, I can be wrong but if it's "unpaged" when your result is above the base paging (100), probably it will accuse as unpaged but you can set this query specifically to retrieve all data with:

let mut query: Query = Query::new("SELECT a, b FROM ks.t");
query.set_page_size(1000); // Debugging purposes maybe?

Probably we can find a better implementation for that, but let's keep it simple for now and make it work.

@Daniel-Boll
Copy link
Owner Author

About the paging, I can be wrong but if it's "unpaged" when your result is above the base paging (100), probably it will accuse as unpaged but you can set this query specifically to retrieve all data with:

Idk because I'm querying the system_schema.columns which brings roughly 500 and it just straight up works.

@danielhe4rt
Copy link
Collaborator

So we don't have a problem here. Let's implement it and in the next driver version we can check how it gonna be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants