I’d like to automate the addition of performance_counter to every endpoint in our application (probably using some sort of macro). It doesn’t have to be called every single time, we could sample it 1 in 100 if it caused additional overhead.
Is this a good idea, or is there a better way? Thanks!
Using defer crate - crates.io: Rust Package Registry
2 Likes
What is your goal of getting the performance counter info per update or query call?
Just so we can have a really lightweight way of monitoring every call, a set and forget macro that gives us profiling information for every endpoint.
I guess we’d only be able to save it for the update calls however, but that’s not a huge deal as they’ll be the ones doing the work.
I could store it in a local HashMap with the endpoint name and the average cycles per call, so if anything was creating a spike in cycles burned we’d be able to find it early.
1 Like
It works. If anybody’s interested in a system like this I’m working on open sourcing it.
2 Likes
The use case makes sense. Have you thought about using Canister Geek as well?
I really wish every call had the instructions and cycles used simply returned with the request. This seems very basic functionality, similar to how Ethereum transactions will have gas used attached to the metadata (or something like that IIRC).
1 Like