@neat.is/core 0.10.6-dev.20261009 → 0.10.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  resolveNeatVersion,
9
9
  startK8sSubstratePolling,
10
10
  writeDaemonRecord
11
- } from "./chunk-ECBRGTB2.js";
11
+ } from "./chunk-OKM4N7GH.js";
12
12
  import {
13
13
  buildSearchIndex,
14
14
  searchProviderFromEnv
@@ -68,7 +68,7 @@ import {
68
68
  startStalenessLoop,
69
69
  upsertConnectorEntry,
70
70
  validateConnectorEntry
71
- } from "./chunk-H2BAPN33.js";
71
+ } from "./chunk-MW2XYLCS.js";
72
72
  import {
73
73
  ProjectNameCollisionError,
74
74
  RegistryError,
@@ -1056,7 +1056,7 @@ import semver from "semver";
1056
1056
 
1057
1057
  // src/installers/templates.ts
1058
1058
  var OTEL_INIT_HEADER = "// Generated by `neat init --apply` (ADR-069). OpenTelemetry auto-instrumentation hook.";
1059
- var OTEL_INIT_STAMP = "// neat-template-version: 8 \u2014 CommonJS TypeScript uses a synchronous bootstrap (#910); OTel init degrades to no-OBSERVED when dependencies are absent (#820); daemon.json endpoint resolution (ADR-096) + layered file-first capture (ADR-090).";
1059
+ var OTEL_INIT_STAMP = "// neat-template-version: 9 \u2014 CommonJS TypeScript uses a synchronous bootstrap (#910); OTel init degrades to no-OBSERVED when dependencies are absent (#820); daemon.json endpoint resolution (ADR-096) + layered file-first capture (ADR-090); spans flushed on exit (#1353).";
1060
1060
  var OTEL_OTLP_HEADERS_JS = "if (process.env.NEAT_OTEL_TOKEN) process.env.OTEL_EXPORTER_OTLP_HEADERS ||= 'Authorization=Bearer%20' + encodeURIComponent(process.env.NEAT_OTEL_TOKEN)";
1061
1061
  var OTEL_OTLP_PROTOCOL_JS = "process.env.OTEL_EXPORTER_OTLP_PROTOCOL ||= 'http/json'";
1062
1062
  var OTEL_ENDPOINT_RESOLVER_CJS = `;(function () {
@@ -1360,6 +1360,31 @@ function __neatInstallFacades() {
1360
1360
  }
1361
1361
  var CALLSITE_PROCESSOR_JS = neatCaptureSource(false);
1362
1362
  var CALLSITE_PROCESSOR_TS = neatCaptureSource(true);
1363
+ function neatFlushOnExitSource(ts) {
1364
+ const anyT = ts ? ": any" : "";
1365
+ return `;(function () {
1366
+ let __neatFlushing${anyT}
1367
+ const __neatFlush = () => {
1368
+ if (!__neatFlushing) {
1369
+ __neatFlushing = new Promise((resolve) => {
1370
+ const t${anyT} = setTimeout(() => resolve(true), 2000)
1371
+ if (t && typeof t.unref === 'function') t.unref()
1372
+ Promise.resolve().then(() => sdk.shutdown()).catch(() => {}).then(() => { clearTimeout(t); resolve(false) })
1373
+ })
1374
+ }
1375
+ return __neatFlushing
1376
+ }
1377
+ // Only a flush that timed out forces the exit; otherwise an app's own
1378
+ // beforeExit cleanup still runs.
1379
+ process.once('beforeExit', (code${anyT}) => { __neatFlush().then((timedOut${anyT}) => { if (timedOut) process.exit(process.exitCode ?? code) }) })
1380
+ for (const sig of ['SIGTERM', 'SIGINT']) {
1381
+ process.once(sig${ts ? " as any" : ""}, () => {
1382
+ const alone = process.listenerCount(sig${ts ? " as any" : ""}) === 0
1383
+ __neatFlush().then(() => { if (alone) process.kill(process.pid, sig) })
1384
+ })
1385
+ }
1386
+ })()`;
1387
+ }
1363
1388
  function neatWireCaptureSource(ts) {
1364
1389
  const providerT = ts ? ": any" : "";
1365
1390
  return `try {
@@ -1412,6 +1437,7 @@ const instrumentations = [getNodeAutoInstrumentations()]
1412
1437
  __INSTRUMENTATION_BLOCK__
1413
1438
  const sdk = new NodeSDK({ instrumentations })
1414
1439
  sdk.start()
1440
+ ${neatFlushOnExitSource(false)}
1415
1441
  ${neatWireCaptureSource(false)}
1416
1442
  } catch (__neatOtelErr) {
1417
1443
  const __neatMsg = String((__neatOtelErr && __neatOtelErr.message) || __neatOtelErr)
@@ -1450,6 +1476,7 @@ const instrumentations = [getNodeAutoInstrumentations()]
1450
1476
  __INSTRUMENTATION_BLOCK__
1451
1477
  const sdk = new NodeSDK({ instrumentations })
1452
1478
  sdk.start()
1479
+ ${neatFlushOnExitSource(false)}
1453
1480
  ${neatWireCaptureSource(false)}
1454
1481
  } catch (__neatOtelErr) {
1455
1482
  const __neatMsg = String((__neatOtelErr && __neatOtelErr.message) || __neatOtelErr)
@@ -1486,6 +1513,7 @@ const instrumentations = [getNodeAutoInstrumentations()]
1486
1513
  __INSTRUMENTATION_BLOCK__
1487
1514
  const sdk = new NodeSDK({ instrumentations })
1488
1515
  sdk.start()
1516
+ ${neatFlushOnExitSource(true)}
1489
1517
  ${neatWireCaptureSource(true)}
1490
1518
  } catch (__neatOtelErr) {
1491
1519
  const __neatMsg = String((__neatOtelErr && __neatOtelErr.message) || __neatOtelErr)
@@ -1623,6 +1651,7 @@ const sdk = new NodeSDK({
1623
1651
  instrumentations: [getNodeAutoInstrumentations()],
1624
1652
  })
1625
1653
  sdk.start()
1654
+ ${neatFlushOnExitSource(true)}
1626
1655
  `;
1627
1656
  var FRAMEWORK_OTEL_INIT_JS_BODY = `${FRAMEWORK_OTEL_INIT_HEADER}
1628
1657
  process.env.OTEL_SERVICE_NAME ||= '__SERVICE_NAME__'
@@ -1638,6 +1667,7 @@ const sdk = new NodeSDK({
1638
1667
  instrumentations: [getNodeAutoInstrumentations()],
1639
1668
  })
1640
1669
  sdk.start()
1670
+ ${neatFlushOnExitSource(false)}
1641
1671
  `;
1642
1672
  function renderFrameworkOtelInit(template, serviceName, projectName) {
1643
1673
  return template.replace(/__SERVICE_NAME__/g, serviceName).replace(/__PROJECT__/g, projectName);