From 2784357924e4564a7958f9b2d3d31afa3643072c Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Tue, 26 Nov 2024 04:42:36 -0800 Subject: [PATCH] chore(examples/redis): use crypto.randomBytes to generate uuid (#2546) Co-authored-by: Trent Mick Co-authored-by: Marc Pichler --- examples/redis/src/server.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/examples/redis/src/server.ts b/examples/redis/src/server.ts index 3227fed8bf..b3a5c1c936 100644 --- a/examples/redis/src/server.ts +++ b/examples/redis/src/server.ts @@ -7,6 +7,7 @@ const tracer = setupTracing('example-redis-server'); import * as express from 'express'; import axios from 'axios'; import * as tracerHandlers from './express-tracer-handlers'; +import { randomBytes } from 'crypto'; const redisPromise = require('./setup-redis').redis; // Setup express @@ -20,12 +21,7 @@ async function setupRoutes() { const redis = await redisPromise; app.get('/run_test', async (req: express.Request, res: express.Response) => { - const uuid = Math.random() - .toString(36) - .substring(2, 15) - + Math.random() - .toString(36) - .substring(2, 15); + const uuid = randomBytes(16).toString('hex'); await axios.get(`http://localhost:${PORT}/set?args=uuid,${uuid}`); const body = await axios.get(`http://localhost:${PORT}/get?args=uuid`);