8000 feat: Add json-output params to watch command by sologgfun · Pull Request #235 · hengyoush/kyanos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Add json-output params to watch command #235

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

Merged
merged 3 commits into from
Jan 2, 2025

Conversation

sologgfun
Copy link
Contributor

Add JSON output parameters to watch command

Changes

  • Added --json-output flag to watch command for programmatic data processing
  • Added --json-output-file flag to specify custom output file path
  • Default JSON output path is set to /tmp/kyanos_watch.json

Features

  • Export request-response data in structured JSON format
  • Each JSON record includes:
    • Detailed timing information (start/end time, various duration metrics)
    • Connection details (protocol, addresses, ports)
    • Content information (request/response sizes and content)
    • Event details (syscall and NIC events)
  • Support both default and custom output paths

Documentation

  • Added JSON output format documentation in both English and Chinese
  • Updated watch command documentation to include JSON output usage

Copy link
vercel bot commented Dec 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kyanos ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 2, 2025 8:03am

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. documentation Improvements or additions to documentation enhancement New feature or request labels Dec 31, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kyanos 🔄 Building (Inspect) Visit Preview 💬 Add feedback Dec 31, 2024 8:08am

@hengyoush
Copy link
Owner

Thanks for your contributions! There are some code conflicts that need to be resolved.

@sologgfun
Copy link
Contributor Author

I made some changes to the code and would like to provide some explanations:

  1. Reason for keeping annotatedRecordAlias instead of using AnnotatedRecord:
    There are many fields that require modifications during serialization, and AnnotatedRecord is a generic structure.
  • The Protocol needs to be converted from an enum value to a string.
  • Side needs to call the String() method for conversion.
  • The IP address needs to call the String() method for conversion.
  • Various time durations need to be converted to milliseconds.
  • Request and Response need to call the FormatToString() method.
  1. Cobra StringVar flag needs an argument:
    This design is difficult to implement:
    --json-output would dump to stdout.
    --json-output=/path/file would output to a file.
    Reference: Getting "flag needs an argument" while flag has the default value spf13/cobra#1756

@hengyoush
Copy link
Owner

I made some changes to the code and would like to provide some explanations:
...

👌,I have no problem.

Specifying stdout is somewhat inconvenient, but in most cases, console output is primarily used for debugging, and debugging generally uses --debug-output. Therefore, I believe it is acceptable.

Copy link
Owner
@hengyoush hengyoush left a comment

Choose a reason for hiding this comment

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

LGTM.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 2, 2025
@hengyoush hengyoush merged commit 1c0dd72 into hengyoush:main Jan 2, 2025
15 checks passed
hengyoush pushed a commit that referenced this pull request Jan 6, 2025
* feat: Add json-output params to watch command

* docs: modify some field explain

* docs: modify column name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants
0