Menu
Open source
uuidv4()
Function returns a random uuid v4 in a string form.
Parameters
Parameter | Type | Description |
---|---|---|
secure (optional) | boolean | By default, uuidv4() uses a standard random number generator. If the secure option is set to true , uuidv4 uses a cryptographically secure random number generator instead. While this adds security, the secure option also makes the function an order of magnitude slower. |
Returns
Type | Description |
---|---|
string | Random UUID v4 string |
Example
JavaScript
import { uuidv4 } from 'https://jslib.k6.io/k6-utils/1.4.0/index.js';
export default function () {
const randomUUID = uuidv4();
console.log(randomUUID); // 35acae14-f7cb-468a-9866-1fc45713149a
}
Was this page helpful?
Related documentation
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video
Performance testing and observability in Grafana Cloud
In this webinar, learn how Grafana Cloud k6 offers you the best developer experience for performance testing.
User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.