mirror of
https://github.com/davidkaya/aryx.git
synced 2026-08-07 12:18:44 +02:00
feat: add Aspire dashboard OTEL workflow
Add OTLP export wiring for the sidecar and dev scripts to launch the standalone Aspire Dashboard during development. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { spawn } from 'node:child_process';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import {
|
||||
createOpenTelemetryEnvironment,
|
||||
startAspireDashboard,
|
||||
stopAspireDashboard,
|
||||
} from './aspireDashboard';
|
||||
|
||||
const scriptDirectory = dirname(fileURLToPath(import.meta.url));
|
||||
const repositoryRoot = resolve(scriptDirectory, '..');
|
||||
const signalExitCodes: Partial<Record<NodeJS.Signals, number>> = {
|
||||
SIGINT: 130,
|
||||
SIGTERM: 143,
|
||||
};
|
||||
|
||||
const dashboard = await startAspireDashboard();
|
||||
|
||||
console.log(`Aspire Dashboard: ${dashboard.dashboardUrl}`);
|
||||
console.log(`Aryx sidecar OTLP endpoint: ${dashboard.otlpGrpcEndpoint}`);
|
||||
|
||||
const child = spawn(process.execPath, ['run', 'dev'], {
|
||||
cwd: repositoryRoot,
|
||||
env: createOpenTelemetryEnvironment(process.env, dashboard.otlpGrpcEndpoint),
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
for (const signal of ['SIGINT', 'SIGTERM'] as const) {
|
||||
process.on(signal, () => {
|
||||
if (child.exitCode === null && child.signalCode === null) {
|
||||
child.kill(signal);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let exitResult: { code: number | null; signal: NodeJS.Signals | null };
|
||||
|
||||
try {
|
||||
exitResult = await new Promise((resolve, reject) => {
|
||||
child.on('error', reject);
|
||||
child.on('exit', (code, signal) => {
|
||||
resolve({ code, signal });
|
||||
});
|
||||
});
|
||||
} finally {
|
||||
if (dashboard.startedByScript) {
|
||||
await stopAspireDashboard();
|
||||
}
|
||||
}
|
||||
|
||||
if (exitResult.signal) {
|
||||
process.exitCode = signalExitCodes[exitResult.signal] ?? 1;
|
||||
} else {
|
||||
process.exitCode = exitResult.code ?? 1;
|
||||
}
|
||||
Reference in New Issue
Block a user