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

Using Capture to save results in CQLSH with Tracing on incorrectly saves the trace details #3307

Conversation

GautamGottipati
Copy link

…ves the trace details

Tried to make initial changes.
Some of the loopholes after these changes :

  1. When we enable capture the self.color becomes false (line 1649 in qlshmain.py), due to this the trace is not colored when printed in shell( sysout) 2) There is some issue with Tracing session when tried to print in file. The Tracing session: does n't appear in the first run, it appears in the next runs.

Thanks for sending a pull request! Here are some tips if you're new here:

  • Ensure you have added or run the appropriate tests for your PR.
  • Be sure to keep the PR description updated to reflect all changes.
  • Write your PR title to summarize what this PR proposes.
  • If possible, provide a concise example to reproduce the issue for a faster review.
  • Read our contributor guidelines
  • If you're making a documentation change, see our guide to documentation contribution

Commit messages should follow the following format:

Using Capture to save results in CQLSH with Tracing on incorrectly saves the trace details


The Cassandra Jira

Copy link
Contributor

@bschoening bschoening left a comment

Choose a reason for hiding this comment

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

  1. In tracing.py:

It seems for output we should use self.shunted_query_out if its not None, otherwise query_out. This is similar (but opposite) to how print_result() uses it.

Shouldn't all the shell.writeresults() go to self.shunted_query_out, which is the original stdout?

  1. There is no color because its saved in shunted_color.

  2. Maybe if print_formatted_result had a boolean arg for useShunted, it could use the shunted_query_out and shunted_color

  3. If possible, there should be a unit test for this. For example, run CAPTURE "/dev/null" with tracing and make sure the stdout has tracing msgs. This is primarily so it doesn't get broken in the future.

@GautamGottipati
Copy link
Author

Hi @bschoening,

Here are some of the observations:
Initially when there is no Capture.
shunted_query_out is None
query_out is <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> which is stdout.

When we start Capturing (example Capture 'demo_capture.txt'):
shunted_query_out is <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> which is stdout
query_out is <_io.TextIOWrapper name='demo_capture.txt' mode='a' encoding='UTF-8'> which is the file demo_capture.txt.

According to the observations
We are not able to get the file information from shunted_query_out. I feel we need to send query_out to shell.writeresults() .
In Tracing.py the shell.print_formatted_result should beshell.print_formatted_result(formatted_names, formatted_values, with_header=True, tty=shell.tty, out=shell.shunted_query_out) in case out is None then output should be query_out.

Still figuring it out. Open for suggestions.

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