-
Notifications
You must be signed in to change notification settings - Fork 82
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
Are calls to add_distribution_value
synchronous or asynchronous? Can they raise errors?
#887
Comments
Hi @thbar! TL;DR: It is safe to call
Yes, they're "synchronous", in that they synchronously communicate with the AppSignal extension via the NIF. But they're not "synchronous" in that they'd block until the value is sent to AppSignal, or anything like that. Communicating through the NIF takes a very short time. This is to say, this should not be a problem -- the value is merely queued in the extension, which will send it to AppSignal asynchronously. (Our own instrumentations interface with the NIF from within Telemetry handlers -- see Ecto for example)
In practice, no. They could raise an error if they're not being invoked correctly -- say, if you were to pass a string as the distribution value instead of a double. As long as the right number of arguments are passed with the right types, no error will be raised. While the integration's NIF interfaces with the AppSignal agent, which is not open source, the NIF bridge itself is publicly available, and you can take a look at the implementation for That said, if an error was somehow raised, the consequence would be that Telemetry would detach the event handler that raised an error. This error would be logged, and your application would no longer emit this metric to AppSignal, but your application would not crash because of it. |
Hi @unflxw! Thanks for the timely & thoughtful answer!
This is what I hoped for, given the type of software 😄 thanks for the confirmation!
Ok! I looked at the code before and indeed was wondering what would happen inside the NIF, would it block or not etc. Many thanks, this is perfect and I can move forward with our implementation. Thank you! |
In:
An example of Ecto instrumentation is provided to show how to track pool statistics (
idle_time
etc) via calls to:One must note, though, that telemetry handlers are run "inline", as explained here:
I looked a bit at the code (which ends up in the NIF), and wondered:
add_distribution_value
calls synchronous?I know that an effort is planned to track those metrics as custom metrics here:
but in the mean time, since I will use the implementation provided in #318 (comment), I would like to understand the potential consequences.
Thanks!
The text was updated successfully, but these errors were encountered: