@burdenoff/be-sdk 2026.1116.2 → 2026.1121.1
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.
|
@@ -10,6 +10,67 @@ import { n as isBunRuntime } from "./bun-runtime-metrics-CPy5D6NT.js";
|
|
|
10
10
|
* still compile and run. The function resolves `undefined` when the SDK
|
|
11
11
|
* isn't available, letting `bootstrapTelemetry` fall back gracefully.
|
|
12
12
|
*/
|
|
13
|
+
const isSamplerModule = (mod) => {
|
|
14
|
+
if (typeof mod !== "object" || mod === null) return false;
|
|
15
|
+
const candidate = mod;
|
|
16
|
+
return typeof candidate.ParentBasedSampler === "function" && typeof candidate.TraceIdRatioBasedSampler === "function";
|
|
17
|
+
};
|
|
18
|
+
const describeError = (error) => error instanceof Error ? error.message : String(error);
|
|
19
|
+
/**
|
|
20
|
+
* Builds `ParentBasedSampler(TraceIdRatioBasedSampler(ratio))`.
|
|
21
|
+
*
|
|
22
|
+
* Candidates, first that works wins:
|
|
23
|
+
* 1. an `@opentelemetry/sdk-trace-base` namespace the caller injected;
|
|
24
|
+
* 2. the `tracing` namespace `@opentelemetry/sdk-node` re-exports. It is the
|
|
25
|
+
* sdk-trace copy NodeSDK itself was built against, so its
|
|
26
|
+
* `@opentelemetry/core` always matches;
|
|
27
|
+
* 3. the consumer's top-level `@opentelemetry/sdk-trace-base`.
|
|
28
|
+
*
|
|
29
|
+
* Candidate 3 alone used to be the only path. Services that also depend on
|
|
30
|
+
* `@envelop/opentelemetry` (which asks for sdk-trace-base `^1.11.0`) get the
|
|
31
|
+
* 1.x copy hoisted to the top level, and with `@opentelemetry/core` pinned to
|
|
32
|
+
* 2.x that copy throws at load time (`TracesSamplerValues` is undefined). The
|
|
33
|
+
* configured ratio was then ignored silently (CORE-48).
|
|
34
|
+
*
|
|
35
|
+
* Each candidate is constructed inside its own try, because a module can load
|
|
36
|
+
* and still fail when its classes are instantiated.
|
|
37
|
+
*/
|
|
38
|
+
async function resolveSampler(input) {
|
|
39
|
+
const ratio = Math.min(1, Math.max(0, input.sampleRatio));
|
|
40
|
+
const failures = [];
|
|
41
|
+
const build = (mod) => new mod.ParentBasedSampler({ root: new mod.TraceIdRatioBasedSampler(ratio) });
|
|
42
|
+
const candidates = [];
|
|
43
|
+
if (input.injectedTraceBase !== void 0) candidates.push({
|
|
44
|
+
source: "injected @opentelemetry/sdk-trace-base",
|
|
45
|
+
get: () => input.injectedTraceBase
|
|
46
|
+
});
|
|
47
|
+
candidates.push({
|
|
48
|
+
source: "@opentelemetry/sdk-node tracing",
|
|
49
|
+
get: () => input.sdkNode?.tracing
|
|
50
|
+
});
|
|
51
|
+
candidates.push({
|
|
52
|
+
source: "@opentelemetry/sdk-trace-base",
|
|
53
|
+
get: input.loadTraceBase
|
|
54
|
+
});
|
|
55
|
+
for (const candidate of candidates) try {
|
|
56
|
+
const mod = await candidate.get();
|
|
57
|
+
if (!isSamplerModule(mod)) {
|
|
58
|
+
failures.push(`${candidate.source}: no ParentBasedSampler/TraceIdRatioBasedSampler export`);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
sampler: build(mod),
|
|
63
|
+
source: candidate.source,
|
|
64
|
+
failures
|
|
65
|
+
};
|
|
66
|
+
} catch (error) {
|
|
67
|
+
failures.push(`${candidate.source}: ${describeError(error)}`);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
sampler: void 0,
|
|
71
|
+
failures
|
|
72
|
+
};
|
|
73
|
+
}
|
|
13
74
|
/** The name `OTEL_NODE_{ENABLED,DISABLED}_INSTRUMENTATIONS` use for `@opentelemetry/instrumentation-runtime-node`. */
|
|
14
75
|
const RUNTIME_NODE_INSTRUMENTATION = "runtime-node";
|
|
15
76
|
/** True when a comma-separated `OTEL_NODE_*_INSTRUMENTATIONS` value names `name` (parsed as auto-instrumentations-node does). */
|
|
@@ -82,15 +143,15 @@ async function createOtelSdk(cfg) {
|
|
|
82
143
|
if (metricsDropReason === void 0) metricsDropReason = "metric reader construction or compatibility check failed";
|
|
83
144
|
metricReader = void 0;
|
|
84
145
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
146
|
+
const samplerResult = await resolveSampler({
|
|
147
|
+
sdkNode: sdkMod,
|
|
148
|
+
injectedTraceBase: cfg.modules?.["@opentelemetry/sdk-trace-base"],
|
|
149
|
+
loadTraceBase: () => importOptionalPeer("@opentelemetry/sdk-trace-base"),
|
|
150
|
+
sampleRatio: cfg.sampleRatio
|
|
151
|
+
});
|
|
152
|
+
const sampler = samplerResult.sampler;
|
|
153
|
+
if (samplerResult.source) console.log(`[sdk] sampler built from ${samplerResult.source}`);
|
|
154
|
+
else console.log(`[sdk] sampler not available (non-fatal): ${samplerResult.failures.join("; ")}`);
|
|
94
155
|
console.log("[sdk] importing @opentelemetry/auto-instrumentations-node...");
|
|
95
156
|
let autoInstrumentations;
|
|
96
157
|
try {
|
|
@@ -148,9 +209,10 @@ async function createOtelSdk(cfg) {
|
|
|
148
209
|
return {
|
|
149
210
|
shutdown: async () => nodeSdk.shutdown(),
|
|
150
211
|
metricsEnabled,
|
|
151
|
-
metricsDropReason
|
|
212
|
+
metricsDropReason,
|
|
213
|
+
...samplerResult.source ? { samplerSource: samplerResult.source } : {}
|
|
152
214
|
};
|
|
153
215
|
}
|
|
154
216
|
|
|
155
217
|
export { createOtelSdk };
|
|
156
|
-
//# sourceMappingURL=sdk-
|
|
218
|
+
//# sourceMappingURL=sdk-BkIS_wTK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-BkIS_wTK.js","names":[],"sources":["../src/telemetry/sdk.ts"],"sourcesContent":["/**\n * Thin wrapper that initializes `@opentelemetry/sdk-node` with the\n * OTLPTrace + OTLPMetric exporters and standard auto-instrumentations.\n *\n * All imports are dynamic so services that haven't installed sdk-node\n * still compile and run. The function resolves `undefined` when the SDK\n * isn't available, letting `bootstrapTelemetry` fall back gracefully.\n */\nimport { importOptionalPeer } from '../utils/import-optional-peer.js';\nimport { isBunRuntime } from './bun-runtime-metrics.js';\nimport type { TelemetryIdGenerator } from './id-generator.js';\nimport type { Boundary, Env } from './index.js';\n\nexport interface OtelSdkConfig {\n serviceName: string;\n serviceVersion: string;\n boundary: Boundary;\n module?: string;\n env: Env;\n otlpEndpoint: string;\n sampleRatio: number;\n /**\n * Optional trace/span id generator handed to NodeSDK's tracer provider.\n * Omitted means the SDK's default random generator.\n */\n idGenerator?: TelemetryIdGenerator;\n /**\n * Pre-loaded OpenTelemetry packages, keyed by package name. A package found\n * here is used as is; any other one is loaded at runtime from the consumer's\n * `node_modules` through `importOptionalPeer`. A service built with\n * `bun build --compile` has no `node_modules` at runtime, so it imports the\n * packages statically and hands them in here.\n */\n modules?: OtelModules;\n}\n\n/** The OpenTelemetry packages `createOtelSdk` can load. */\nexport type OtelPeerPackage =\n | '@opentelemetry/api'\n | '@opentelemetry/auto-instrumentations-node'\n | '@opentelemetry/exporter-metrics-otlp-http'\n | '@opentelemetry/exporter-trace-otlp-http'\n | '@opentelemetry/resources'\n | '@opentelemetry/sdk-metrics'\n | '@opentelemetry/sdk-node'\n | '@opentelemetry/sdk-trace-base'\n | '@opentelemetry/semantic-conventions';\n\n/** Module namespaces injected in place of runtime imports (see `OtelSdkConfig.modules`). */\nexport type OtelModules = Partial<Record<OtelPeerPackage, unknown>>;\n\nexport interface OtelSdkHandle {\n shutdown: () => Promise<void>;\n metricsEnabled: boolean;\n metricsDropReason?: string;\n /**\n * Where the configured ratio sampler came from, or `undefined` when no\n * sampler could be built and NodeSDK fell back to its own default sampler.\n */\n samplerSource?: SamplerSource;\n}\n\n/** The module a ratio sampler was built from (see `resolveSampler`). */\nexport type SamplerSource =\n 'injected @opentelemetry/sdk-trace-base' | '@opentelemetry/sdk-node tracing' | '@opentelemetry/sdk-trace-base';\n\ninterface SamplerModule {\n ParentBasedSampler: new (init: Record<string, unknown>) => unknown;\n TraceIdRatioBasedSampler: new (ratio: number) => unknown;\n}\n\nconst isSamplerModule = (mod: unknown): mod is SamplerModule => {\n if (typeof mod !== 'object' || mod === null) return false;\n const candidate = mod as Partial<Record<keyof SamplerModule, unknown>>;\n return typeof candidate.ParentBasedSampler === 'function' && typeof candidate.TraceIdRatioBasedSampler === 'function';\n};\n\nexport interface ResolveSamplerInput {\n /** The loaded `@opentelemetry/sdk-node` namespace. */\n sdkNode: unknown;\n /** An `@opentelemetry/sdk-trace-base` namespace passed in through `OtelSdkConfig.modules`. */\n injectedTraceBase?: unknown;\n /** Loads `@opentelemetry/sdk-trace-base` from the consumer's `node_modules`. */\n loadTraceBase: () => Promise<unknown>;\n sampleRatio: number;\n}\n\nexport interface ResolveSamplerResult {\n sampler: unknown;\n source?: SamplerSource;\n /** One entry per candidate that was missing or could not build a sampler. */\n failures: string[];\n}\n\nconst describeError = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\n/**\n * Builds `ParentBasedSampler(TraceIdRatioBasedSampler(ratio))`.\n *\n * Candidates, first that works wins:\n * 1. an `@opentelemetry/sdk-trace-base` namespace the caller injected;\n * 2. the `tracing` namespace `@opentelemetry/sdk-node` re-exports. It is the\n * sdk-trace copy NodeSDK itself was built against, so its\n * `@opentelemetry/core` always matches;\n * 3. the consumer's top-level `@opentelemetry/sdk-trace-base`.\n *\n * Candidate 3 alone used to be the only path. Services that also depend on\n * `@envelop/opentelemetry` (which asks for sdk-trace-base `^1.11.0`) get the\n * 1.x copy hoisted to the top level, and with `@opentelemetry/core` pinned to\n * 2.x that copy throws at load time (`TracesSamplerValues` is undefined). The\n * configured ratio was then ignored silently (CORE-48).\n *\n * Each candidate is constructed inside its own try, because a module can load\n * and still fail when its classes are instantiated.\n */\nexport async function resolveSampler(input: ResolveSamplerInput): Promise<ResolveSamplerResult> {\n const ratio = Math.min(1, Math.max(0, input.sampleRatio));\n const failures: string[] = [];\n const build = (mod: SamplerModule): unknown =>\n new mod.ParentBasedSampler({ root: new mod.TraceIdRatioBasedSampler(ratio) });\n\n const candidates: Array<{ source: SamplerSource; get: () => unknown }> = [];\n if (input.injectedTraceBase !== undefined) {\n candidates.push({ source: 'injected @opentelemetry/sdk-trace-base', get: () => input.injectedTraceBase });\n }\n candidates.push({\n source: '@opentelemetry/sdk-node tracing',\n get: () => (input.sdkNode as { tracing?: unknown } | null | undefined)?.tracing,\n });\n candidates.push({ source: '@opentelemetry/sdk-trace-base', get: input.loadTraceBase });\n\n for (const candidate of candidates) {\n try {\n const mod = await candidate.get();\n if (!isSamplerModule(mod)) {\n failures.push(`${candidate.source}: no ParentBasedSampler/TraceIdRatioBasedSampler export`);\n continue;\n }\n return { sampler: build(mod), source: candidate.source, failures };\n } catch (error) {\n failures.push(`${candidate.source}: ${describeError(error)}`);\n }\n }\n return { sampler: undefined, failures };\n}\n\n/** Per-instrumentation config handed to `getNodeAutoInstrumentations`, keyed by package name. */\nexport type AutoInstrumentationConfig = Record<string, { enabled: boolean }>;\n\n/** The name `OTEL_NODE_{ENABLED,DISABLED}_INSTRUMENTATIONS` use for `@opentelemetry/instrumentation-runtime-node`. */\nconst RUNTIME_NODE_INSTRUMENTATION = 'runtime-node';\n\n/** True when a comma-separated `OTEL_NODE_*_INSTRUMENTATIONS` value names `name` (parsed as auto-instrumentations-node does). */\nconst listsInstrumentation = (value: string | undefined, name: string): boolean =>\n value !== undefined && value.split(',').some((entry) => entry.trim() === name);\n\n/**\n * The config be-sdk hands to `getNodeAutoInstrumentations`.\n *\n * - `instrumentation-fs` is always off.\n * - `instrumentation-runtime-node` is off under Bun unless\n * `OTEL_NODE_ENABLED_INSTRUMENTATIONS` names `runtime-node` (BOFF-12287). On\n * every 60 s OTLP metric export it reads `v8.getHeapSpaceStatistics()`,\n * which Bun implements as a synchronous walk of the whole heap: a 0.1–1.4 s\n * block once a minute on the prod gateways, during which no request is\n * served. Event-loop lag stays visible through prom-client's\n * `nodejs_eventloop_lag_*`. Dropped: the OTel `v8js_*`,\n * `nodejs_eventloop_delay_*`, `nodejs_eventloop_utilization_*` and\n * `nodejs_eventloop_time_*` series, which no dashboard or alert reads.\n *\n * auto-instrumentations-node lets a programmatic `enabled: false` win over\n * both env vars, so the opt-in has to be checked here. Under Node nothing\n * changes: the env vars keep their usual meaning.\n */\nexport function autoInstrumentationConfig(\n env: Readonly<Record<string, string | undefined>> = process.env,\n bun: boolean = isBunRuntime()\n): AutoInstrumentationConfig {\n const config: AutoInstrumentationConfig = {\n '@opentelemetry/instrumentation-fs': { enabled: false },\n };\n if (bun && !listsInstrumentation(env['OTEL_NODE_ENABLED_INSTRUMENTATIONS'], RUNTIME_NODE_INSTRUMENTATION)) {\n config['@opentelemetry/instrumentation-runtime-node'] = { enabled: false };\n }\n return config;\n}\n\ntype Thenable = {\n then: (onfulfilled?: (value: void) => void, onrejected?: (reason: unknown) => void) => unknown;\n};\n\nconst isThenable = (value: unknown): value is Thenable => {\n return typeof value === 'object' && value !== null && typeof (value as { then?: unknown }).then === 'function';\n};\n\nconst asyncDisposeMetricReader = async (metricReaderCandidate: unknown): Promise<void> => {\n const shutdown = (metricReaderCandidate as { shutdown?: () => void | Promise<void> }).shutdown;\n if (typeof shutdown === 'function') {\n const result = shutdown.call(metricReaderCandidate) as unknown;\n if (isThenable(result)) await result;\n }\n};\n\nexport async function createOtelSdk(cfg: OtelSdkConfig): Promise<OtelSdkHandle> {\n const load = (name: OtelPeerPackage): Promise<unknown> =>\n cfg.modules?.[name] !== undefined ? Promise.resolve(cfg.modules[name]) : importOptionalPeer(name);\n console.log('[sdk] importing @opentelemetry/sdk-node...');\n const sdkMod = (await load('@opentelemetry/sdk-node')) as {\n NodeSDK: new (init: Record<string, unknown>) => {\n start: () => void;\n shutdown: () => Promise<void>;\n };\n };\n\n console.log('[sdk] importing @opentelemetry/resources...');\n const resources = (await load('@opentelemetry/resources')) as {\n resourceFromAttributes: (attrs: Record<string, string | number>) => unknown;\n };\n\n console.log('[sdk] importing @opentelemetry/semantic-conventions...');\n const sem = (await load('@opentelemetry/semantic-conventions')) as Record<string, string>;\n\n console.log('[sdk] importing @opentelemetry/exporter-trace-otlp-http...');\n const traceExp = (await load('@opentelemetry/exporter-trace-otlp-http')) as {\n OTLPTraceExporter: new (init: Record<string, string>) => unknown;\n };\n\n console.log('[sdk] importing @opentelemetry/exporter-metrics-otlp-http...');\n let metricsExp: { OTLPMetricExporter?: new (init: Record<string, string>) => unknown } | undefined;\n try {\n metricsExp = (await load('@opentelemetry/exporter-metrics-otlp-http')) as typeof metricsExp;\n } catch {\n metricsExp = undefined;\n console.log('[sdk] metrics exporter not available (non-fatal)');\n }\n\n let metricReader: unknown;\n let metricsEnabled = false;\n let metricsDropReason: string | undefined;\n if (metricsExp?.OTLPMetricExporter) {\n try {\n const metricsSdk = (await load('@opentelemetry/sdk-metrics')) as {\n PeriodicExportingMetricReader: new (init: Record<string, unknown>) => unknown;\n };\n const candidate = new metricsSdk.PeriodicExportingMetricReader({\n exporter: new metricsExp.OTLPMetricExporter({\n url: `${cfg.otlpEndpoint.replace(/\\/$/, '')}/v1/metrics`,\n }),\n });\n // Pre-flight API compatibility check. Some OTel package version\n // combinations construct `PeriodicExportingMetricReader` successfully\n // but lack `setMetricProducer` on the prototype chain (mixed\n // sdk-metrics versions, or runtime-specific class-inheritance\n // quirks — Bun has surfaced this in the past). Without the check,\n // `NodeSDK.start()` may register the global tracer provider BEFORE\n // it tries to call `setMetricProducer` and throws — leaving the\n // global tracer pointing at a half-initialized provider whose\n // span pipeline never drains. Skipping the metric reader when the\n // API isn't there avoids that whole failure mode in one pass.\n const setProducer = (candidate as { setMetricProducer?: unknown }).setMetricProducer;\n if (typeof setProducer === 'function') {\n metricReader = candidate;\n metricsEnabled = true;\n } else {\n metricsDropReason =\n 'setMetricProducer is not a function on PeriodicExportingMetricReader; skipping metrics path';\n await asyncDisposeMetricReader(candidate);\n metricReader = undefined;\n }\n } catch {\n if (metricsDropReason === undefined) {\n metricsDropReason = 'metric reader construction or compatibility check failed';\n }\n metricReader = undefined;\n }\n }\n\n const samplerResult = await resolveSampler({\n sdkNode: sdkMod,\n injectedTraceBase: cfg.modules?.['@opentelemetry/sdk-trace-base'],\n loadTraceBase: () => importOptionalPeer('@opentelemetry/sdk-trace-base'),\n sampleRatio: cfg.sampleRatio,\n });\n const sampler = samplerResult.sampler;\n if (samplerResult.source) {\n console.log(`[sdk] sampler built from ${samplerResult.source}`);\n } else {\n console.log(`[sdk] sampler not available (non-fatal): ${samplerResult.failures.join('; ')}`);\n }\n\n // Some services have auto-instrumentations installed; optional.\n console.log('[sdk] importing @opentelemetry/auto-instrumentations-node...');\n let autoInstrumentations: unknown[] | undefined;\n try {\n const auto = (await load('@opentelemetry/auto-instrumentations-node')) as {\n getNodeAutoInstrumentations: (cfg?: Record<string, unknown>) => unknown[];\n };\n const instrumentationConfig = autoInstrumentationConfig();\n autoInstrumentations = auto.getNodeAutoInstrumentations(instrumentationConfig);\n console.log('[sdk] auto-instrumentations loaded');\n if (instrumentationConfig['@opentelemetry/instrumentation-runtime-node']?.enabled === false) {\n console.log(\n '[sdk] runtime-node instrumentation off under Bun (its heap statistics stall the event loop); ' +\n 'list runtime-node in OTEL_NODE_ENABLED_INSTRUMENTATIONS to turn it on'\n );\n }\n } catch {\n autoInstrumentations = undefined;\n console.log('[sdk] auto-instrumentations not available (non-fatal)');\n }\n\n const serviceNamespaceByBoundary: Record<Boundary, string> = {\n wspace: 'workspaces',\n global: 'tenant',\n gateway: 'gateways',\n };\n const resourceAttributes: Record<string, string> = {\n [sem['SEMRESATTRS_SERVICE_NAME'] ?? 'service.name']: cfg.serviceName,\n [sem['SEMRESATTRS_SERVICE_VERSION'] ?? 'service.version']: cfg.serviceVersion,\n [sem['SEMRESATTRS_SERVICE_NAMESPACE'] ?? 'service.namespace']: serviceNamespaceByBoundary[cfg.boundary],\n [sem['SEMRESATTRS_DEPLOYMENT_ENVIRONMENT'] ?? 'deployment.environment']: cfg.env,\n 'burdenoff.boundary': cfg.boundary,\n };\n if (cfg.module) resourceAttributes['burdenoff.module'] = cfg.module;\n const serviceInstanceId = process.env['POD_NAME'] ?? process.env['HOSTNAME'];\n if (serviceInstanceId) resourceAttributes['service.instance.id'] = serviceInstanceId;\n const clusterName = process.env['CLUSTER_NAME'];\n if (clusterName) {\n resourceAttributes['cluster'] = clusterName;\n resourceAttributes['k8s.cluster.name'] = clusterName;\n }\n\n const resource = resources.resourceFromAttributes(resourceAttributes);\n\n const traceExporter = new traceExp.OTLPTraceExporter({\n url: `${cfg.otlpEndpoint.replace(/\\/$/, '')}/v1/traces`,\n });\n\n // Single NodeSDK, single start. The pre-flight `setMetricProducer`\n // check above means we never pass an incompatible metric reader into\n // NodeSDK construction — so we no longer need the prior catch+rebuild\n // fallback dance, which had its own side-effect: the failed first\n // NodeSDK could leave the global tracer provider partially registered,\n // and the second NodeSDK's `setGlobalTracerProvider` becomes a no-op\n // — meaning spans flow into the FIRST (broken) provider and never\n // reach the exporter. Eliminating the fallback eliminates that hazard.\n console.log('[sdk] constructing NodeSDK...');\n const nodeSdk = new sdkMod.NodeSDK({\n resource,\n traceExporter,\n ...(metricReader ? { metricReader } : {}),\n ...(sampler ? { sampler } : {}),\n ...(cfg.idGenerator ? { idGenerator: cfg.idGenerator } : {}),\n ...(autoInstrumentations ? { instrumentations: autoInstrumentations } : {}),\n });\n console.log('[sdk] NodeSDK constructed, calling start()...');\n // NodeSDK.start() returns void in modern versions and Promise<void> in older\n // ones. Cast to a permissive thenable shape so awaiting works either way\n // without tripping `@typescript-eslint/await-thenable`.\n const startResult = nodeSdk.start() as unknown;\n if (isThenable(startResult)) {\n await startResult;\n }\n console.log('[sdk] NodeSDK started');\n\n // Stash the @opentelemetry/api reference for pino-logger's mixin.\n try {\n (globalThis as unknown as { __otelApi?: unknown }).__otelApi = await load('@opentelemetry/api');\n console.log('[sdk] @opentelemetry/api stashed for pino mixin');\n } catch {\n console.log('[sdk] @opentelemetry/api stash failed (non-fatal)');\n }\n\n console.log('[sdk] OTel SDK initialization complete');\n return {\n shutdown: async (): Promise<void> => nodeSdk.shutdown(),\n metricsEnabled,\n metricsDropReason,\n ...(samplerResult.source ? { samplerSource: samplerResult.source } : {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAuEA,MAAM,mBAAmB,QAAuC;CAC9D,IAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM,OAAO;CACpD,MAAM,YAAY;CAClB,OAAO,OAAO,UAAU,uBAAuB,cAAc,OAAO,UAAU,6BAA6B;AAC7G;AAmBA,MAAM,iBAAiB,UAA4B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;;;;;;;;;;;;;;;;;;;;AAqBxG,eAAsB,eAAe,OAA2D;CAC9F,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,MAAM,WAAW,CAAC;CACxD,MAAM,WAAqB,CAAC;CAC5B,MAAM,SAAS,QACb,IAAI,IAAI,mBAAmB,EAAE,MAAM,IAAI,IAAI,yBAAyB,KAAK,EAAE,CAAC;CAE9E,MAAM,aAAmE,CAAC;CAC1E,IAAI,MAAM,sBAAsB,QAC9B,WAAW,KAAK;EAAE,QAAQ;EAA0C,WAAW,MAAM;CAAkB,CAAC;CAE1G,WAAW,KAAK;EACd,QAAQ;EACR,WAAY,MAAM,SAAsD;CAC1E,CAAC;CACD,WAAW,KAAK;EAAE,QAAQ;EAAiC,KAAK,MAAM;CAAc,CAAC;CAErF,KAAK,MAAM,aAAa,YACtB,IAAI;EACF,MAAM,MAAM,MAAM,UAAU,IAAI;EAChC,IAAI,CAAC,gBAAgB,GAAG,GAAG;GACzB,SAAS,KAAK,GAAG,UAAU,OAAO,wDAAwD;GAC1F;EACF;EACA,OAAO;GAAE,SAAS,MAAM,GAAG;GAAG,QAAQ,UAAU;GAAQ;EAAS;CACnE,SAAS,OAAO;EACd,SAAS,KAAK,GAAG,UAAU,OAAO,IAAI,cAAc,KAAK,GAAG;CAC9D;CAEF,OAAO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
|
352
352
|
if (resolveOtelSdkEnabled()) {
|
|
353
353
|
console.log("[telemetry] OTel SDK bootstrap starting...");
|
|
354
354
|
try {
|
|
355
|
-
const { createOtelSdk } = await import("../sdk-
|
|
355
|
+
const { createOtelSdk } = await import("../sdk-BkIS_wTK.js");
|
|
356
356
|
otelSdk = await createOtelSdk({
|
|
357
357
|
serviceName: cfg.serviceName,
|
|
358
358
|
serviceVersion,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/be-sdk",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.1121.1",
|
|
4
4
|
"description": "Backend SDK for Burdenoff products providing unified access to notifications, RBAC, activity tracking, usage monitoring, and more",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -230,6 +230,7 @@
|
|
|
230
230
|
"access": "public"
|
|
231
231
|
},
|
|
232
232
|
"overrides": {
|
|
233
|
+
"effect": "3.22.4",
|
|
233
234
|
"@graphql-tools/utils": "12.0.3",
|
|
234
235
|
"hono": "4.13.12",
|
|
235
236
|
"valibot": "1.5.0",
|
package/dist/sdk-DqIqX-Ue.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-DqIqX-Ue.js","names":[],"sources":["../src/telemetry/sdk.ts"],"sourcesContent":["/**\n * Thin wrapper that initializes `@opentelemetry/sdk-node` with the\n * OTLPTrace + OTLPMetric exporters and standard auto-instrumentations.\n *\n * All imports are dynamic so services that haven't installed sdk-node\n * still compile and run. The function resolves `undefined` when the SDK\n * isn't available, letting `bootstrapTelemetry` fall back gracefully.\n */\nimport { importOptionalPeer } from '../utils/import-optional-peer.js';\nimport { isBunRuntime } from './bun-runtime-metrics.js';\nimport type { TelemetryIdGenerator } from './id-generator.js';\nimport type { Boundary, Env } from './index.js';\n\nexport interface OtelSdkConfig {\n serviceName: string;\n serviceVersion: string;\n boundary: Boundary;\n module?: string;\n env: Env;\n otlpEndpoint: string;\n sampleRatio: number;\n /**\n * Optional trace/span id generator handed to NodeSDK's tracer provider.\n * Omitted means the SDK's default random generator.\n */\n idGenerator?: TelemetryIdGenerator;\n /**\n * Pre-loaded OpenTelemetry packages, keyed by package name. A package found\n * here is used as is; any other one is loaded at runtime from the consumer's\n * `node_modules` through `importOptionalPeer`. A service built with\n * `bun build --compile` has no `node_modules` at runtime, so it imports the\n * packages statically and hands them in here.\n */\n modules?: OtelModules;\n}\n\n/** The OpenTelemetry packages `createOtelSdk` can load. */\nexport type OtelPeerPackage =\n | '@opentelemetry/api'\n | '@opentelemetry/auto-instrumentations-node'\n | '@opentelemetry/exporter-metrics-otlp-http'\n | '@opentelemetry/exporter-trace-otlp-http'\n | '@opentelemetry/resources'\n | '@opentelemetry/sdk-metrics'\n | '@opentelemetry/sdk-node'\n | '@opentelemetry/sdk-trace-base'\n | '@opentelemetry/semantic-conventions';\n\n/** Module namespaces injected in place of runtime imports (see `OtelSdkConfig.modules`). */\nexport type OtelModules = Partial<Record<OtelPeerPackage, unknown>>;\n\nexport interface OtelSdkHandle {\n shutdown: () => Promise<void>;\n metricsEnabled: boolean;\n metricsDropReason?: string;\n}\n\n/** Per-instrumentation config handed to `getNodeAutoInstrumentations`, keyed by package name. */\nexport type AutoInstrumentationConfig = Record<string, { enabled: boolean }>;\n\n/** The name `OTEL_NODE_{ENABLED,DISABLED}_INSTRUMENTATIONS` use for `@opentelemetry/instrumentation-runtime-node`. */\nconst RUNTIME_NODE_INSTRUMENTATION = 'runtime-node';\n\n/** True when a comma-separated `OTEL_NODE_*_INSTRUMENTATIONS` value names `name` (parsed as auto-instrumentations-node does). */\nconst listsInstrumentation = (value: string | undefined, name: string): boolean =>\n value !== undefined && value.split(',').some((entry) => entry.trim() === name);\n\n/**\n * The config be-sdk hands to `getNodeAutoInstrumentations`.\n *\n * - `instrumentation-fs` is always off.\n * - `instrumentation-runtime-node` is off under Bun unless\n * `OTEL_NODE_ENABLED_INSTRUMENTATIONS` names `runtime-node` (BOFF-12287). On\n * every 60 s OTLP metric export it reads `v8.getHeapSpaceStatistics()`,\n * which Bun implements as a synchronous walk of the whole heap: a 0.1–1.4 s\n * block once a minute on the prod gateways, during which no request is\n * served. Event-loop lag stays visible through prom-client's\n * `nodejs_eventloop_lag_*`. Dropped: the OTel `v8js_*`,\n * `nodejs_eventloop_delay_*`, `nodejs_eventloop_utilization_*` and\n * `nodejs_eventloop_time_*` series, which no dashboard or alert reads.\n *\n * auto-instrumentations-node lets a programmatic `enabled: false` win over\n * both env vars, so the opt-in has to be checked here. Under Node nothing\n * changes: the env vars keep their usual meaning.\n */\nexport function autoInstrumentationConfig(\n env: Readonly<Record<string, string | undefined>> = process.env,\n bun: boolean = isBunRuntime()\n): AutoInstrumentationConfig {\n const config: AutoInstrumentationConfig = {\n '@opentelemetry/instrumentation-fs': { enabled: false },\n };\n if (bun && !listsInstrumentation(env['OTEL_NODE_ENABLED_INSTRUMENTATIONS'], RUNTIME_NODE_INSTRUMENTATION)) {\n config['@opentelemetry/instrumentation-runtime-node'] = { enabled: false };\n }\n return config;\n}\n\ntype Thenable = {\n then: (onfulfilled?: (value: void) => void, onrejected?: (reason: unknown) => void) => unknown;\n};\n\nconst isThenable = (value: unknown): value is Thenable => {\n return typeof value === 'object' && value !== null && typeof (value as { then?: unknown }).then === 'function';\n};\n\nconst asyncDisposeMetricReader = async (metricReaderCandidate: unknown): Promise<void> => {\n const shutdown = (metricReaderCandidate as { shutdown?: () => void | Promise<void> }).shutdown;\n if (typeof shutdown === 'function') {\n const result = shutdown.call(metricReaderCandidate) as unknown;\n if (isThenable(result)) await result;\n }\n};\n\nexport async function createOtelSdk(cfg: OtelSdkConfig): Promise<OtelSdkHandle> {\n const load = (name: OtelPeerPackage): Promise<unknown> =>\n cfg.modules?.[name] !== undefined ? Promise.resolve(cfg.modules[name]) : importOptionalPeer(name);\n console.log('[sdk] importing @opentelemetry/sdk-node...');\n const sdkMod = (await load('@opentelemetry/sdk-node')) as {\n NodeSDK: new (init: Record<string, unknown>) => {\n start: () => void;\n shutdown: () => Promise<void>;\n };\n };\n\n console.log('[sdk] importing @opentelemetry/resources...');\n const resources = (await load('@opentelemetry/resources')) as {\n resourceFromAttributes: (attrs: Record<string, string | number>) => unknown;\n };\n\n console.log('[sdk] importing @opentelemetry/semantic-conventions...');\n const sem = (await load('@opentelemetry/semantic-conventions')) as Record<string, string>;\n\n console.log('[sdk] importing @opentelemetry/exporter-trace-otlp-http...');\n const traceExp = (await load('@opentelemetry/exporter-trace-otlp-http')) as {\n OTLPTraceExporter: new (init: Record<string, string>) => unknown;\n };\n\n console.log('[sdk] importing @opentelemetry/exporter-metrics-otlp-http...');\n let metricsExp: { OTLPMetricExporter?: new (init: Record<string, string>) => unknown } | undefined;\n try {\n metricsExp = (await load('@opentelemetry/exporter-metrics-otlp-http')) as typeof metricsExp;\n } catch {\n metricsExp = undefined;\n console.log('[sdk] metrics exporter not available (non-fatal)');\n }\n\n let metricReader: unknown;\n let metricsEnabled = false;\n let metricsDropReason: string | undefined;\n if (metricsExp?.OTLPMetricExporter) {\n try {\n const metricsSdk = (await load('@opentelemetry/sdk-metrics')) as {\n PeriodicExportingMetricReader: new (init: Record<string, unknown>) => unknown;\n };\n const candidate = new metricsSdk.PeriodicExportingMetricReader({\n exporter: new metricsExp.OTLPMetricExporter({\n url: `${cfg.otlpEndpoint.replace(/\\/$/, '')}/v1/metrics`,\n }),\n });\n // Pre-flight API compatibility check. Some OTel package version\n // combinations construct `PeriodicExportingMetricReader` successfully\n // but lack `setMetricProducer` on the prototype chain (mixed\n // sdk-metrics versions, or runtime-specific class-inheritance\n // quirks — Bun has surfaced this in the past). Without the check,\n // `NodeSDK.start()` may register the global tracer provider BEFORE\n // it tries to call `setMetricProducer` and throws — leaving the\n // global tracer pointing at a half-initialized provider whose\n // span pipeline never drains. Skipping the metric reader when the\n // API isn't there avoids that whole failure mode in one pass.\n const setProducer = (candidate as { setMetricProducer?: unknown }).setMetricProducer;\n if (typeof setProducer === 'function') {\n metricReader = candidate;\n metricsEnabled = true;\n } else {\n metricsDropReason =\n 'setMetricProducer is not a function on PeriodicExportingMetricReader; skipping metrics path';\n await asyncDisposeMetricReader(candidate);\n metricReader = undefined;\n }\n } catch {\n if (metricsDropReason === undefined) {\n metricsDropReason = 'metric reader construction or compatibility check failed';\n }\n metricReader = undefined;\n }\n }\n\n console.log('[sdk] importing @opentelemetry/sdk-trace-base for sampler...');\n let sampler: unknown;\n try {\n const traceBase = (await load('@opentelemetry/sdk-trace-base')) as {\n ParentBasedSampler: new (init: Record<string, unknown>) => unknown;\n TraceIdRatioBasedSampler: new (ratio: number) => unknown;\n };\n sampler = new traceBase.ParentBasedSampler({\n root: new traceBase.TraceIdRatioBasedSampler(Math.min(1, Math.max(0, cfg.sampleRatio))),\n });\n } catch {\n sampler = undefined;\n console.log('[sdk] sampler not available (non-fatal)');\n }\n\n // Some services have auto-instrumentations installed; optional.\n console.log('[sdk] importing @opentelemetry/auto-instrumentations-node...');\n let autoInstrumentations: unknown[] | undefined;\n try {\n const auto = (await load('@opentelemetry/auto-instrumentations-node')) as {\n getNodeAutoInstrumentations: (cfg?: Record<string, unknown>) => unknown[];\n };\n const instrumentationConfig = autoInstrumentationConfig();\n autoInstrumentations = auto.getNodeAutoInstrumentations(instrumentationConfig);\n console.log('[sdk] auto-instrumentations loaded');\n if (instrumentationConfig['@opentelemetry/instrumentation-runtime-node']?.enabled === false) {\n console.log(\n '[sdk] runtime-node instrumentation off under Bun (its heap statistics stall the event loop); ' +\n 'list runtime-node in OTEL_NODE_ENABLED_INSTRUMENTATIONS to turn it on'\n );\n }\n } catch {\n autoInstrumentations = undefined;\n console.log('[sdk] auto-instrumentations not available (non-fatal)');\n }\n\n const serviceNamespaceByBoundary: Record<Boundary, string> = {\n wspace: 'workspaces',\n global: 'tenant',\n gateway: 'gateways',\n };\n const resourceAttributes: Record<string, string> = {\n [sem['SEMRESATTRS_SERVICE_NAME'] ?? 'service.name']: cfg.serviceName,\n [sem['SEMRESATTRS_SERVICE_VERSION'] ?? 'service.version']: cfg.serviceVersion,\n [sem['SEMRESATTRS_SERVICE_NAMESPACE'] ?? 'service.namespace']: serviceNamespaceByBoundary[cfg.boundary],\n [sem['SEMRESATTRS_DEPLOYMENT_ENVIRONMENT'] ?? 'deployment.environment']: cfg.env,\n 'burdenoff.boundary': cfg.boundary,\n };\n if (cfg.module) resourceAttributes['burdenoff.module'] = cfg.module;\n const serviceInstanceId = process.env['POD_NAME'] ?? process.env['HOSTNAME'];\n if (serviceInstanceId) resourceAttributes['service.instance.id'] = serviceInstanceId;\n const clusterName = process.env['CLUSTER_NAME'];\n if (clusterName) {\n resourceAttributes['cluster'] = clusterName;\n resourceAttributes['k8s.cluster.name'] = clusterName;\n }\n\n const resource = resources.resourceFromAttributes(resourceAttributes);\n\n const traceExporter = new traceExp.OTLPTraceExporter({\n url: `${cfg.otlpEndpoint.replace(/\\/$/, '')}/v1/traces`,\n });\n\n // Single NodeSDK, single start. The pre-flight `setMetricProducer`\n // check above means we never pass an incompatible metric reader into\n // NodeSDK construction — so we no longer need the prior catch+rebuild\n // fallback dance, which had its own side-effect: the failed first\n // NodeSDK could leave the global tracer provider partially registered,\n // and the second NodeSDK's `setGlobalTracerProvider` becomes a no-op\n // — meaning spans flow into the FIRST (broken) provider and never\n // reach the exporter. Eliminating the fallback eliminates that hazard.\n console.log('[sdk] constructing NodeSDK...');\n const nodeSdk = new sdkMod.NodeSDK({\n resource,\n traceExporter,\n ...(metricReader ? { metricReader } : {}),\n ...(sampler ? { sampler } : {}),\n ...(cfg.idGenerator ? { idGenerator: cfg.idGenerator } : {}),\n ...(autoInstrumentations ? { instrumentations: autoInstrumentations } : {}),\n });\n console.log('[sdk] NodeSDK constructed, calling start()...');\n // NodeSDK.start() returns void in modern versions and Promise<void> in older\n // ones. Cast to a permissive thenable shape so awaiting works either way\n // without tripping `@typescript-eslint/await-thenable`.\n const startResult = nodeSdk.start() as unknown;\n if (isThenable(startResult)) {\n await startResult;\n }\n console.log('[sdk] NodeSDK started');\n\n // Stash the @opentelemetry/api reference for pino-logger's mixin.\n try {\n (globalThis as unknown as { __otelApi?: unknown }).__otelApi = await load('@opentelemetry/api');\n console.log('[sdk] @opentelemetry/api stashed for pino mixin');\n } catch {\n console.log('[sdk] @opentelemetry/api stash failed (non-fatal)');\n }\n\n console.log('[sdk] OTel SDK initialization complete');\n return {\n shutdown: async (): Promise<void> => nodeSdk.shutdown(),\n metricsEnabled,\n metricsDropReason,\n };\n}\n"],"mappings":";;;;;;;;;;;;;AA6DA,MAAM,+BAA+B;;AAGrC,MAAM,wBAAwB,OAA2B,SACvD,UAAU,UAAa,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,UAAU,MAAM,KAAK,MAAM,IAAI;;;;;;;;;;;;;;;;;;;AAoB/E,SAAgB,0BACd,MAAoD,QAAQ,KAC5D,MAAe,aAAa,GACD;CAC3B,MAAM,SAAoC,EACxC,qCAAqC,EAAE,SAAS,MAAM,EACxD;CACA,IAAI,OAAO,CAAC,qBAAqB,IAAI,uCAAuC,4BAA4B,GACtG,OAAO,iDAAiD,EAAE,SAAS,MAAM;CAE3E,OAAO;AACT;AAMA,MAAM,cAAc,UAAsC;CACxD,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAQ,MAA6B,SAAS;AACtG;AAEA,MAAM,2BAA2B,OAAO,0BAAkD;CACxF,MAAM,WAAY,sBAAoE;CACtF,IAAI,OAAO,aAAa,YAAY;EAClC,MAAM,SAAS,SAAS,KAAK,qBAAqB;EAClD,IAAI,WAAW,MAAM,GAAG,MAAM;CAChC;AACF;AAEA,eAAsB,cAAc,KAA4C;CAC9E,MAAM,QAAQ,SACZ,IAAI,UAAU,UAAU,SAAY,QAAQ,QAAQ,IAAI,QAAQ,KAAK,IAAI,mBAAmB,IAAI;CAClG,QAAQ,IAAI,4CAA4C;CACxD,MAAM,SAAU,MAAM,KAAK,yBAAyB;CAOpD,QAAQ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