Skip to content

Commit 2784357

Browse files
trivikrtrentmpichlermarc
authored
chore(examples/redis): use crypto.randomBytes to generate uuid (open-telemetry#2546)
Co-authored-by: Trent Mick <trentm@gmail.com> Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
1 parent 468222b commit 2784357

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

examples/redis/src/server.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const tracer = setupTracing('example-redis-server');
77
import * as express from 'express';
88
import axios from 'axios';
99
import * as tracerHandlers from './express-tracer-handlers';
10+
import { randomBytes } from 'crypto';
1011
const redisPromise = require('./setup-redis').redis;
1112

1213
// Setup express
@@ -20,12 +21,7 @@ async function setupRoutes() {
2021
const redis = await redisPromise;
2122

2223
app.get('/run_test', async (req: express.Request, res: express.Response) => {
23-
const uuid = Math.random()
24-
.toString(36)
25-
.substring(2, 15)
26-
+ Math.random()
27-
.toString(36)
28-
.substring(2, 15);
24+
const uuid = randomBytes(16).toString('hex');
2925
await axios.get(`http://localhost:${PORT}/set?args=uuid,${uuid}`);
3026
const body = await axios.get(`http://localhost:${PORT}/get?args=uuid`);
3127

0 commit comments

Comments
 (0)