Skip to content

Commit

Permalink
chore(examples/redis): use crypto.randomBytes to generate uuid (open-…
Browse files Browse the repository at this point in the history
…telemetry#2546)

Co-authored-by: Trent Mick <[email protected]>
Co-authored-by: Marc Pichler <[email protected]>
  • Loading branch information
3 people authored Nov 26, 2024
1 parent 468222b commit 2784357
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions examples/redis/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`);

Expand Down

0 comments on commit 2784357

Please sign in to comment.