
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
exframe-metrics
Advanced tools
Utility functions for instrumenting metrics.
npm install exframe-metrics
instrument
function takes a function as input, adds duration histogram and count metrics to it, executes it, and returns a Promise
that is fulfilled with result of the function.
const myFunction = () => 'banana';
const result = await instrument(myFunction);
console.log(result);
// > banana
console.log(await prometheusClient.register.metrics());
// # HELP function_myFunction_duration_seconds Length of time, in seconds, the function took to complete
// # TYPE function_myFunction_duration_seconds histogram
// function_myFunction_duration_seconds_bucket{le="0.005"} 1
// function_myFunction_duration_seconds_bucket{le="0.01"} 1
// function_myFunction_duration_seconds_bucket{le="0.025"} 1
// function_myFunction_duration_seconds_bucket{le="0.05"} 1
// function_myFunction_duration_seconds_bucket{le="0.1"} 1
// function_myFunction_duration_seconds_bucket{le="0.25"} 1
// function_myFunction_duration_seconds_bucket{le="0.5"} 1
// function_myFunction_duration_seconds_bucket{le="1"} 1
// function_myFunction_duration_seconds_bucket{le="2.5"} 1
// function_myFunction_duration_seconds_bucket{le="5"} 1
// function_myFunction_duration_seconds_bucket{le="10"} 1
// function_myFunction_duration_seconds_bucket{le="+Inf"} 1
// function_myFunction_duration_seconds_sum 0.000182651
// function_myFunction_duration_seconds_count 1
// # HELP function_myFunction_calls_total Total number of times the function was called
// # TYPE function_myFunction_calls_total counter
// function_myFunction_calls_total 1
lazyInstrument
function has a similar outcome as instrument
except that it does not execute the input function directly and instead returns a different async function, instrumented with metrics, that can be called later. Useful for generating middleware functions.
const myFunction = () => 'banana';
const myDeferredFunction = await lazyInstrument(myFunction);
const result = await myDeferredFunction();
console.log(result);
// > banana
Returns a Promise
that is either fulfilled with the input function's result, or rejected with an error if the function throws.
Type: function
Function to be instrumented. Default metrics added are:
"function_<function_name>_duration_seconds"
metricName
if provided). The default name of this metrics is: "function_<function_name>_calls_total"
Type: object
Type: String
Overrides the fn
name to use for the base part of the metric names. Note: This property is required if an anonymous function is provided
Type: String
String to prepend to an auto-generated metric name. Ignored if metricName
is provided
FAQs
Utility functions for instrumenting metrics.
The npm package exframe-metrics receives a total of 1,437 weekly downloads. As such, exframe-metrics popularity was classified as popular.
We found that exframe-metrics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.