Nothing Special   »   [go: up one dir, main page]

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 RestRequestListener #1144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

felldo
Copy link
Member
@felldo felldo commented Oct 9, 2022

Checklist

Changelog

  • Added a new listener RestRequestListener which dispatches each time a rest request is executed

Description

This PR will add a new listener which will be dispatched each time a rest request is executed. This is helpful for i.e. monitoring purposes.
Furthermore this PR will now auto close the Response bodies like the Javadoc of OkHttp states.
In addition some data was moved to the OkHttpResponseImpl from the RestRequestResult

Footnotes

  1. At least started a running bot instance with your changes and triggered an event so your changed code gets executed.

@Saladoc
Copy link
Member
Saladoc commented Oct 10, 2022

I'm really not sure if I'm a fan of this. Not because I don't see the value of being able to intercept and monitor the rest requests, but because we're mixing in a low-level event with all the high-level ones.

All events passed through Javacords event bus relate to actual state changes on discords side - granted, they may be caused by (bot) user actions but still, the events displayed comes from discord. This would be the first event that happens on our side and also the only one that's on a low technical level rather than representing a state change.

I like the idea, but I am not at all convinced just slapping it on the event dispatcher. Things that deal with the internals of Javacord should go a different way. The idea of specific modules (#356 and #805) has been brought up before and I feel a "Monitoring Module" that can be activated and deactivated on startup as needed and interacted with would be a far more robust and adequate solution.

@felldo
Copy link
Member Author
felldo commented Oct 10, 2022

I see what you mean. Usually I would agree on moving it into it's own module but isn't it a bit overkill? While the cache and rest module will be quiet large and encapsulate the code very good like it should be, I don't think there a lot of metrics that we can actually dispatch. We could for example in addition to the rest requests also expose the websocket events (there's already a PR that suggest to add an event for any gateway event #917) but I can't think of anything that might be worth exposing too for monitoring purposes. Even if there are 2 or 3 more possible metrics, it will most likely be just a few lines to actually expose them when doing it like in this PR.
Also what do you think how should the module look like and how should we interact with it to get the data if we do not dispatch it?

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

Successfully merging this pull request may close these issues.

2 participants