'static metrics::set_recorder(..) and metrics::Recorder trait #382
-
Why does metrics::set_recorder input a Couldn't the methods (describe_counter, register_counter, etc.) input a Apologies if this is a silly question, I'm building a CloudWatch embedded metrics recorder intended for AWS Lambda functions and worked around this with an unsafe cast back to |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
They could be changed to take Generally speaking, there's hardly ever an issue with the lifetime of the It strikes me that if you're already leaking a bunch of atomics in a way to get static references to them, then you shouldn't have any problems: you can create an |
Beta Was this translation helpful? Give feedback.
-
Is there a better way to do this? The constraint that I will only have X counters + gauges and X is known at init is fine.
|
Beta Was this translation helpful? Give feedback.
-
I found the CounterFn and GaugeFn implementations for AtomicU64. From there things fell into place without the unsafe code. Thanks so much for taking the time to answer my question, much appreciated. |
Beta Was this translation helpful? Give feedback.
-
Crate published |
Beta Was this translation helpful? Give feedback.
Just store
Vec<Arc<AtomicU64>>
and get a clone of them when creating the handles inregister_counter
, etc. There's no need to do anything with&'static
.