-
Notifications
You must be signed in to change notification settings - Fork 81
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 example for actix-web framework #53
Comments
I think you are confusing
https://doc.rust-lang.org/std/clone/trait.Clone.html I think a good rule of thumb whether a type should implement
First I would like to question "isn't good for performance". In case this is happening mostly on a single core, memory synchronization costs are likely low. Asked from a different perspective, how would you like to share an object between concurrent executions without some mechanism of synchronization? We could invent some lock-free / wait-free mechanism, though I doubt that is worth the effort (see below). This is a serious question. Happy for suggestions. To dive a bit deeper into the matter of performance here, the lock only enforces mutual exclusion on the metric collection path. I would expect this path to never be a bottleneck on your end. In other words I would not expect more than ~1 scrape per second. Note that metric recording can happen concurrently. Let me know if the above is of some help @oriontvv. |
@mxinden Hi, thanks for the feedback and sorry for late reply.
About the question - I thought that it's possible to avoid blocking like an example for tide do(I don't see any blocking for let registry: Arc<Registry> = Arc::new(Registry::default());
HttpServer::new(move || {
App::new()
.app_data(registry.clone())
})
.bind(("127.0.0.1", 8080))?
.run()
.await
96 | HttpServer::new(move || {
| ^^^^^^^^^^^^^^^ `dyn SendEncodeMetric` cannot be shared between threads safely
|
On vacation right now, though #57 (comment) might help in the meantime. |
Hi guys, thanks for your contribution!
There is an issue with using the client with actix-web framework.
Because
Registry
doesn't implementCopy
- the only working solution I've found is to wrap it withMutex
. But it requires locking at least on each collecting of metrics which isn't good for performance. Are there any other suggestions?The text was updated successfully, but these errors were encountered: