encore
encore copied to clipboard
runtimes/js: add support for custom metrics
Adds support for creating custom metrics in typescript apps. Depends on #2109
Inspired by the implementation in the go runtime. Metrics needs to be defined within a service, and will automatically add the service label.
This implementation is backed by a SharedArrayBuffer, where each u64 slot is a metric value, created from js by the main thread. From js we do atomic operation to update values on this buffer, and from rust we do atomic load when collecting the metrics. The rust runtime is use to coordinate what slot should be used for a label set, so that we can support multiple workers updating the same metric.
All committers have signed the CLA.