-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Better JSON output support #37
Comments
We may not just keep them simply as |
Indeed. The goal of this issue is to exactly do that. |
Is this still open? |
Yes, feel free to reach out in case you wonder what needs to be done. My example on top is not really "JSON" standard. |
@pouriyajamshidi
Something like type JSONEvent struct{
// Mandatory
EventType string `json:"event_type"` // something like "ping", "stop", "stats", "retry", ... basically one for each "event type"
Message string `json:"message"` // user-readable message, we could reuse the same message that we have now
// Optional fields for better parsing.
// This would duplicate data from message for 3rd party programs to parse
// so that they don't need to use string split or regex to give info from our messages
TotalUptime time.duration `json:"total_update,omitempty"`
TotalDowntime time.duration `json:"total_downtime,omitempty"`
// other fields...
} I didn't really think deep about the format, it's just a general IDEA. P.S. Why are comments using a |
Hey @ravsii,
I rather keep things simple and easier to work with. If your proposal of splitting it in another file leads to a cleaner code base, I have no objections. My main issue is with programs that end up with like 15 different files for a simple thing. Rather common among OOP lovers. 😄
It is fine. As stated above, it is better to keep things simple. So if some information is not required, there is no need to cram it there. Nonetheless, think of this JSON output as something closely similar to what we send out to Let me know if you wanna brainstorm further and take your time thinking about a clean solution.
Not quite sure if I understood this one. If you mean in the code, you can do multiline comments with that. instead of using Thanks a lot! |
Guess that's me then, haha. I asked because I often saw such CLI's code is being in the root But I was just asking here, it's not a suggestion.
How about I try to implement it and submit a draft pull request, so you can see how it turned out and make suggestions? I think there are so many nuances (mainly "results" screen) and it's better to address each individually.
Sorry, just a nitpick from me. I've never seen Thanks for the answers @pouriyajamshidi, I'll start working on it then! |
Right. different projects use different approaches. This project was an excuse for me to learn Go at the time and since there was no official guide on how to structure your program, I just put everything in the root. 😄
Sounds good to me! Thanks in advance.
Ah, I see. My C "background" has spilt into Go. 😄 We had another very active contributor who also used that
My pleasure. Thanks and good luck. P.s. Please make sure to rebase to version 1.21.2. Just pushed some stuff. |
Summary
We have introduced a preliminary JSON output support with which can be activated using the
-j
flag. For instance:The ultimate goal is to have the output in a way that is easily extractable in form of keys and values so with tools such as
jq
to feed to the monitoring solutions.Further discussion might be necessary to determine how and what exactly needs to be emitted.
The text was updated successfully, but these errors were encountered: