Stabilize logging, correlation IDs, service-account Jira auth, and direct approver reminder DMs while splitting the monolith into focused modules with Compose-based deployment. Co-authored-by: Cursor <cursoragent@cursor.com>
23 lines
605 B
JavaScript
23 lines
605 B
JavaScript
import { AsyncLocalStorage } from 'async_hooks';
|
|
import { randomUUID } from 'crypto';
|
|
|
|
const correlationStore = new AsyncLocalStorage();
|
|
|
|
export function createCorrelationId({ issueKey, routeName } = {}) {
|
|
const shortId = randomUUID().split('-')[0];
|
|
if (issueKey) {
|
|
return `${issueKey}-${shortId}`;
|
|
}
|
|
if (routeName) {
|
|
return `${routeName}-${shortId}`;
|
|
}
|
|
return shortId;
|
|
}
|
|
|
|
export function getCorrelationId() {
|
|
return correlationStore.getStore();
|
|
}
|
|
|
|
export function runWithCorrelationId(correlationId, fn) {
|
|
return correlationStore.run(correlationId, fn);
|
|
}
|