fix(worker): add reqId to logger for better traceability

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-02-19 10:33:42 +01:00
parent c4258bbccd
commit 59012526e2
5 changed files with 25 additions and 5 deletions

View File

@@ -29,6 +29,7 @@ export function getStringHeaders(headers: FastifyRequest['headers']) {
'openpanel-sdk-name',
'openpanel-sdk-version',
'openpanel-client-id',
'request-id',
],
headers,
),

View File

@@ -40,7 +40,12 @@ export async function parseIp(ip?: string): Promise<GeoLocation> {
}
const hash = crypto.createHash('sha256').update(ip).digest('hex');
const cached = await getRedisCache().get(`geo:${hash}`);
const cached = await getRedisCache()
.get(`geo:${hash}`)
.catch(() => {
logger.warn('Failed to get geo location from cache', { hash });
return null;
});
if (cached) {
return JSON.parse(cached);
@@ -69,7 +74,7 @@ export async function parseIp(ip?: string): Promise<GeoLocation> {
`geo:${hash}`,
JSON.stringify(geo),
'EX',
60 * 30,
60 * 60 * 24,
);
return geo;