-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Add machine readable (e.g. JSON) output format to messenger:stats
command
#48583
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
Comments
The idea is nice, thanks for your motivation to improve this grate framework. However, the main reason of showing the human readable output as a result of console command in the terminal is that we as human enter such commands to check sth meaningful for us.The idea of filtering the results based on the expected JSON keys "json | jq '.doctrine.count" is so cool and time saving possibility, but could be shorter and easier to write in comparison of represented one. Best regards Your fan, Mahbod |
Notice, the command is |
messenger:count
commandmessenger:stats
command
@mahbodsh thanks for the feedback. Sure the idea for the current output is so that a human can execute the command and easily check the output. But my idea would be that in addition we have a machine readable output that we could use for automation, like said, e.g. for monitoring etc. Let me outline the concrete use case I have so it's maybe a bit more clear what my intentions are. When I added the messenger to one of my applications, I built a command that just prints the number of messages in a given queue and I monitor that value with a monitoring system to detect when the queue gets full and maybe doesn't get processed, or not processed fast enough which might indicate an issue, or a need for more workers. The new
So for me it's not about saving time or having the shortest command, but rather to have an output tailored to use cases like the one outlined above. But it's just a suggestion, so if you have a better idea or some improvements, feel free to propose them :) @maxbeckers thanks, you're right, I adjusted the title and description accordingly 👍 (I guess I just copy/pasted it from the original PR) |
Thank you for this suggestion. |
Friendly ping? Should this still be open? I will close if I don't hear anything. |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
@carsonbot It would be great if you can reopen the issue. It seems there is still not a possibility for a machine readable out of the messenger transport statistics. My use case would be to integrate this with the |
It looks like this issue is stalled as nobody started working on it. The best way to revive it would be to create a pull request implementing the wanted feature. |
I'll see if I can make a PR soon with json output |
…ats` command (xvilo) This PR was squashed before being merged into the 7.2 branch. Discussion ---------- [Messenger] Add `--format` option to the `messenger:stats` command | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | Fix #48583 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT As requested in #48583 add a way to output different in formats for `messenger:stats` command. This can be more easily used in, for example, `jq` or with external automations/scripts and such. Considerations I made: - To not, yet, make different classes for the output. In case a new output format is added this might be handy. - To not use an enum for output format, do we want this? - To ignore warnings for now, except for the `uncountable_transports`. If we want to warning in there, what format? Commits ------- 0e9f458 [Messenger] Add `--format` option to the `messenger:stats` command
Description
The new
messenger:stats
(see #46571) command is nice to see how many messages are in your queues, but I think we can still improve that a bit. At the momentmessenger:stats
only supports printing the output to a nicely formatted table, which is fine if a human is reading the output, but it's not that machine-readable.It would be nice to have the option to use some different output format, so you can get the message count in a machine-readable format that you could e.g. feed into a monitoring system, use it as part of a system for auto-scaling workers etc.
I can see that some other symfony commands support a
--format
argument with a default oftext
or similar, providing different output formats such as e.g.json
, which could also be an option here.Down below I prepared an example using JSON as output format.
Not sure how we could treat those 'uncountable transports' best. Maybe with an exit code other than 0 or setting the count to
null
.So I'd like to hear your opinion on that. Would you like to see / use such a feature?
Example
In case we already think that maybe in future there will be more information to add for each transport, we could already make the values objects as well, but just have a
count
property for now to prevent BC break when adding more information, not sure if that's necessary, or too far-sighted already though 😅The text was updated successfully, but these errors were encountered: