-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck-redis.ts
More file actions
executable file
·48 lines (39 loc) · 1.39 KB
/
check-redis.ts
File metadata and controls
executable file
·48 lines (39 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env tsx
import { createClient } from 'redis';
import dotenv from 'dotenv';
// Type-safe environment variable access
function _getEnv(key: string, defaultValue?: string): string {
const value = process.env[key];
if (value === undefined) {
if (defaultValue !== undefined) return defaultValue;
throw new Error(`Environment variable ${key} is required`);
}
return value;
}
function _getOptionalEnv(key: string): string | undefined {
return process.env[key];
}
dotenv.config();
async function checkRedis() {
const client = createClient({ url: process.env['REDIS_URL'] });
await client.connect();
const keys = await client.keys('trace:*');
console.log('Redis trace keys:', keys.length);
if (keys.length > 0) {
console.log('Sample keys:', keys.slice(0, 3));
// Using hGetAll since we store as hash
const sample = await client.hGetAll(keys[0]);
console.log('Sample trace fields:', Object.keys(sample));
console.log('Sample trace data size:', sample.data?.length || 0, 'bytes');
console.log(
'Sample trace compressed:',
sample.compressed === 'true' ? 'yes' : 'no'
);
}
const scoreIndex = await client.zCard('traces:by_score');
const timeIndex = await client.zCard('traces:by_time');
console.log('Score index entries:', scoreIndex);
console.log('Time index entries:', timeIndex);
await client.quit();
}
checkRedis().catch(console.error);