-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
Missing Async support #1005
Comments
This is unfortunately a long standing issue. The fact that PHP is not async as it is, makes this hard to implement. Returning |
Unfortunately the interface doesn't allow me to do that. I don't really care if the wait is there for the default implementation as it is admittedly much more common use case. My point is that currently the interface itself doesn't allow an async implementation. |
Unfortunately by design the Unified API allows supporting an asyncronous API under the hood but regardless is meant to not expose any sign of it to the public. There is a lot of debate on this, and for what is worth I agree that returning |
Is someone who is in charge of designing this so-called "Unified API" aware of this serious drawback? Is it being worked on? I of course agree that this kind of change needs a new major release. So what? Can we make some progress towards it? |
There are similar issues here and there in various SDK repositories (e.g. the one I referenced above), so I'm pretty sure the Sentry guys do know this drawback. About making progress towards it, I don't think that anything will happen in the short time seeing the huge amount of time that passed since the opening of the first issue about this and the replies in it, I'm sorry |
@enumag in amphp you can create a worker pool and push those sentry requests to the pool where they are executed synchronously. Using a pool allows to no wait for another request to be finished first. It's not the very best solution, but you would do the same for example to communicate with mongodb (because they don't have async interfaces for PHP either). |
Looking at the
Another way to go about it is to reword Of course, that's a semantic change and would be a silently breaking change. I'm not familiar with the implementation here to assess the impact of doing this in user code though. It might be perfectly fine to have a custom transport that never returns event IDs. |
One temporary way around this problem is the following: Spin off a php file in a child-process ("exec php filename.php") that talks to Sentry. When the code execution of the child-process is completed, flush will be called on the library to submit the data to Sentry. Since it's contained in a different process, all is done without blocking your mainloop. For ReactPHP, Clue's Peek library does this (returns the results as a promise): The downside of course is that you loose the stack-trace since the request is executed in a different process altogether. So it requires being really descriptive in your errors/warning. But, it does work in a non-blocking fashion. |
This should be possible since |
I have a blog post on how I made sentry work with amphp: https://www.sasaprolic.com/2020/10/sentry-and-amphp.html |
curl_multi_init sentry php can actually cause your project to go down via blocking on external operations with this crap sentry library |
At the moment, this library isn't fit to be used in async event loop environment such as Amphp or ReactPHP. While it internally uses asynchronous http client, the API itself is not asynchronous.
The
HttpTransport
callswait()
which ofc can't be used in an async event loop.You could say that I can implement my own HttpTransport but the real problem is the
TransportInterface
. Which states that the send method should return either the event id or null on failure. In async environment I of course don't know if it failed or not since I can't wait for it so the interface is effectively impossible to fulfill. The best I can do is to return aPromise<string|null>
.By reading the documentation that this library isn't tied to any specific http client and that the used http client should be async I was hopeful that it might be fit to be used in async environment too. I'm very disappointed to see that it's actually not the case.
The text was updated successfully, but these errors were encountered: