encore icon indicating copy to clipboard operation
encore copied to clipboard

runtimes/js: add support for custom metrics

Open fredr opened this issue 4 months ago • 1 comments

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.

fredr avatar Oct 30 '25 12:10 fredr

All committers have signed the CLA.

encore-cla[bot] avatar Oct 30 '25 12:10 encore-cla[bot]