@burdenoff/be-sdk 2026.1125.1 → 2026.1127.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.
|
@@ -1,6 +1,132 @@
|
|
|
1
1
|
import { t as importOptionalPeer } from "./import-optional-peer-B82VYxeX.js";
|
|
2
2
|
import { n as isBunRuntime } from "./bun-runtime-metrics-CPy5D6NT.js";
|
|
3
3
|
|
|
4
|
+
// src/telemetry/instrumentations.ts
|
|
5
|
+
/**
|
|
6
|
+
* Which OpenTelemetry instrumentations `createOtelSdk` registers (BOFF-16818).
|
|
7
|
+
*
|
|
8
|
+
* `@opentelemetry/auto-instrumentations-node` imports every one of its ~39
|
|
9
|
+
* bundled instrumentation packages as soon as it is loaded, whether or not a
|
|
10
|
+
* service uses the library behind it, and each registers a module-load hook.
|
|
11
|
+
* In a Bun GraphQL subgraph that costs about 13 MiB of RSS and 0.5–1.5 s of
|
|
12
|
+
* start-up CPU for instrumentations that never produce a span. The fleet's
|
|
13
|
+
* traces come from a short list of libraries, so by default be-sdk imports
|
|
14
|
+
* only those packages, one by one, and never loads the meta package.
|
|
15
|
+
*
|
|
16
|
+
* Selection (first match wins):
|
|
17
|
+
* 1. `BOFF_OTEL_INSTRUMENTATIONS=auto` → the full auto-instrumentations set.
|
|
18
|
+
* 2. `BOFF_OTEL_INSTRUMENTATIONS=<comma list>` (`http,pg,…`) → exactly those.
|
|
19
|
+
* 3. `OTEL_NODE_ENABLED_INSTRUMENTATIONS` or `OTEL_NODE_DISABLED_INSTRUMENTATIONS`
|
|
20
|
+
* set → the full set, filtered by those standard variables as before.
|
|
21
|
+
* 4. The caller injected `@opentelemetry/auto-instrumentations-node` through
|
|
22
|
+
* `OtelSdkConfig.modules` (a `bun build --compile` binary that has no
|
|
23
|
+
* `node_modules`) → the full set, as before.
|
|
24
|
+
* 5. Otherwise → `DEFAULT_INSTRUMENTATIONS`.
|
|
25
|
+
*
|
|
26
|
+
* When none of the explicit packages can be loaded (a service that installs
|
|
27
|
+
* only the meta package under an isolated linker), `createOtelSdk` falls back to
|
|
28
|
+
* the full set, so a service never ends up with no instrumentation at all.
|
|
29
|
+
*/
|
|
30
|
+
/** The env var that picks the instrumentation set (`auto` or a comma-separated list). */
|
|
31
|
+
const INSTRUMENTATIONS_ENV = "BOFF_OTEL_INSTRUMENTATIONS";
|
|
32
|
+
/**
|
|
33
|
+
* The libraries the fleet's traces and dashboards come from: outbound HTTP
|
|
34
|
+
* (`http`, `undici` for `fetch`), Postgres through the Prisma pg adapter,
|
|
35
|
+
* Redis/Valkey clients, GraphQL execution, pino log correlation, the AWS SDK
|
|
36
|
+
* and DataLoader batches.
|
|
37
|
+
*/
|
|
38
|
+
const DEFAULT_INSTRUMENTATIONS = [
|
|
39
|
+
"http",
|
|
40
|
+
"undici",
|
|
41
|
+
"pg",
|
|
42
|
+
"ioredis",
|
|
43
|
+
"redis",
|
|
44
|
+
"graphql",
|
|
45
|
+
"pino",
|
|
46
|
+
"aws-sdk",
|
|
47
|
+
"dataloader"
|
|
48
|
+
];
|
|
49
|
+
/**
|
|
50
|
+
* Export names that do not follow `<Pascal name>Instrumentation`. Any other
|
|
51
|
+
* package is read through the first export whose name ends in `Instrumentation`.
|
|
52
|
+
*/
|
|
53
|
+
const EXPORT_NAMES = {
|
|
54
|
+
http: "HttpInstrumentation",
|
|
55
|
+
undici: "UndiciInstrumentation",
|
|
56
|
+
pg: "PgInstrumentation",
|
|
57
|
+
ioredis: "IORedisInstrumentation",
|
|
58
|
+
redis: "RedisInstrumentation",
|
|
59
|
+
graphql: "GraphQLInstrumentation",
|
|
60
|
+
pino: "PinoInstrumentation",
|
|
61
|
+
"aws-sdk": "AwsInstrumentation",
|
|
62
|
+
dataloader: "DataloaderInstrumentation"
|
|
63
|
+
};
|
|
64
|
+
/** The package that holds the instrumentation called `name` (`pg` → `@opentelemetry/instrumentation-pg`). */
|
|
65
|
+
const instrumentationPackage = (name) => `@opentelemetry/instrumentation-${name}`;
|
|
66
|
+
const parseList = (value) => [...new Set(value.split(",").map((entry) => entry.trim().toLowerCase()).filter((entry) => entry.length > 0))];
|
|
67
|
+
const isSet = (value) => value !== void 0 && value.trim().length > 0;
|
|
68
|
+
/** Decides between the full auto-instrumentations set and an explicit list (see the module comment). */
|
|
69
|
+
function planInstrumentations(env = process.env, autoInjected = false) {
|
|
70
|
+
const raw = env["BOFF_OTEL_INSTRUMENTATIONS"]?.trim() ?? "";
|
|
71
|
+
if (raw.toLowerCase() === "auto") return {
|
|
72
|
+
mode: "auto",
|
|
73
|
+
reason: `${INSTRUMENTATIONS_ENV}=auto`
|
|
74
|
+
};
|
|
75
|
+
if (raw.length > 0) {
|
|
76
|
+
const names = parseList(raw);
|
|
77
|
+
if (names.length > 0) return {
|
|
78
|
+
mode: "explicit",
|
|
79
|
+
names,
|
|
80
|
+
reason: INSTRUMENTATIONS_ENV
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (isSet(env["OTEL_NODE_ENABLED_INSTRUMENTATIONS"]) || isSet(env["OTEL_NODE_DISABLED_INSTRUMENTATIONS"])) return {
|
|
84
|
+
mode: "auto",
|
|
85
|
+
reason: "OTEL_NODE_{ENABLED,DISABLED}_INSTRUMENTATIONS is set"
|
|
86
|
+
};
|
|
87
|
+
if (autoInjected) return {
|
|
88
|
+
mode: "auto",
|
|
89
|
+
reason: "auto-instrumentations-node was injected"
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
mode: "explicit",
|
|
93
|
+
names: [...DEFAULT_INSTRUMENTATIONS],
|
|
94
|
+
reason: "default list"
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** The instrumentation class a loaded package exports, or undefined when there is none. */
|
|
98
|
+
function instrumentationClass(name, mod) {
|
|
99
|
+
if (typeof mod !== "object" || mod === null) return void 0;
|
|
100
|
+
const exports = mod;
|
|
101
|
+
const known = EXPORT_NAMES[name];
|
|
102
|
+
const candidate = known !== void 0 ? exports[known] : Object.entries(exports).find(([key, value]) => key.endsWith("Instrumentation") && typeof value === "function")?.[1];
|
|
103
|
+
return typeof candidate === "function" ? candidate : void 0;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Imports and instantiates each named instrumentation. A package that is not
|
|
107
|
+
* installed or does not export an instrumentation is skipped and reported,
|
|
108
|
+
* never fatal.
|
|
109
|
+
*/
|
|
110
|
+
async function loadExplicitInstrumentations(names, load) {
|
|
111
|
+
const result = {
|
|
112
|
+
instances: [],
|
|
113
|
+
loaded: [],
|
|
114
|
+
missing: []
|
|
115
|
+
};
|
|
116
|
+
for (const name of names) try {
|
|
117
|
+
const Instrumentation = instrumentationClass(name, await load(instrumentationPackage(name)));
|
|
118
|
+
if (Instrumentation === void 0) {
|
|
119
|
+
result.missing.push(`${name}: no instrumentation export`);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
result.instances.push(new Instrumentation());
|
|
123
|
+
result.loaded.push(name);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
result.missing.push(`${name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
|
|
4
130
|
// src/telemetry/sdk.ts
|
|
5
131
|
/**
|
|
6
132
|
* Thin wrapper that initializes `@opentelemetry/sdk-node` with the
|
|
@@ -152,9 +278,21 @@ async function createOtelSdk(cfg) {
|
|
|
152
278
|
const sampler = samplerResult.sampler;
|
|
153
279
|
if (samplerResult.source) console.log(`[sdk] sampler built from ${samplerResult.source}`);
|
|
154
280
|
else console.log(`[sdk] sampler not available (non-fatal): ${samplerResult.failures.join("; ")}`);
|
|
155
|
-
console.log("[sdk] importing @opentelemetry/auto-instrumentations-node...");
|
|
156
281
|
let autoInstrumentations;
|
|
157
|
-
|
|
282
|
+
const plan = planInstrumentations(process.env, cfg.modules?.["@opentelemetry/auto-instrumentations-node"] !== void 0);
|
|
283
|
+
if (plan.mode === "explicit") {
|
|
284
|
+
const explicit = await loadExplicitInstrumentations(plan.names, (specifier) => {
|
|
285
|
+
const injected = cfg.modules?.[specifier];
|
|
286
|
+
return injected !== void 0 ? Promise.resolve(injected) : importOptionalPeer(specifier);
|
|
287
|
+
});
|
|
288
|
+
if (explicit.instances.length > 0) {
|
|
289
|
+
autoInstrumentations = explicit.instances;
|
|
290
|
+
console.log(`[sdk] instrumentations (${plan.reason}): ${explicit.loaded.join(",")}`);
|
|
291
|
+
if (explicit.missing.length > 0) console.log(`[sdk] instrumentations skipped: ${explicit.missing.join("; ")}`);
|
|
292
|
+
} else console.log(`[sdk] none of the explicit instrumentations could be loaded (${explicit.missing.join("; ")}); falling back to auto-instrumentations-node`);
|
|
293
|
+
} else console.log(`[sdk] full auto-instrumentations set (${plan.reason})`);
|
|
294
|
+
if (autoInstrumentations === void 0) try {
|
|
295
|
+
console.log("[sdk] importing @opentelemetry/auto-instrumentations-node...");
|
|
158
296
|
const auto = await load("@opentelemetry/auto-instrumentations-node");
|
|
159
297
|
const instrumentationConfig = autoInstrumentationConfig();
|
|
160
298
|
autoInstrumentations = auto.getNodeAutoInstrumentations(instrumentationConfig);
|
|
@@ -215,4 +353,4 @@ async function createOtelSdk(cfg) {
|
|
|
215
353
|
}
|
|
216
354
|
|
|
217
355
|
export { createOtelSdk };
|
|
218
|
-
//# sourceMappingURL=sdk-
|
|
356
|
+
//# sourceMappingURL=sdk-7TBR987n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-7TBR987n.js","names":[],"sources":["../src/telemetry/instrumentations.ts","../src/telemetry/sdk.ts"],"sourcesContent":["/**\n * Which OpenTelemetry instrumentations `createOtelSdk` registers (BOFF-16818).\n *\n * `@opentelemetry/auto-instrumentations-node` imports every one of its ~39\n * bundled instrumentation packages as soon as it is loaded, whether or not a\n * service uses the library behind it, and each registers a module-load hook.\n * In a Bun GraphQL subgraph that costs about 13 MiB of RSS and 0.5–1.5 s of\n * start-up CPU for instrumentations that never produce a span. The fleet's\n * traces come from a short list of libraries, so by default be-sdk imports\n * only those packages, one by one, and never loads the meta package.\n *\n * Selection (first match wins):\n * 1. `BOFF_OTEL_INSTRUMENTATIONS=auto` → the full auto-instrumentations set.\n * 2. `BOFF_OTEL_INSTRUMENTATIONS=<comma list>` (`http,pg,…`) → exactly those.\n * 3. `OTEL_NODE_ENABLED_INSTRUMENTATIONS` or `OTEL_NODE_DISABLED_INSTRUMENTATIONS`\n * set → the full set, filtered by those standard variables as before.\n * 4. The caller injected `@opentelemetry/auto-instrumentations-node` through\n * `OtelSdkConfig.modules` (a `bun build --compile` binary that has no\n * `node_modules`) → the full set, as before.\n * 5. Otherwise → `DEFAULT_INSTRUMENTATIONS`.\n *\n * When none of the explicit packages can be loaded (a service that installs\n * only the meta package under an isolated linker), `createOtelSdk` falls back to\n * the full set, so a service never ends up with no instrumentation at all.\n */\n\n/** The env var that picks the instrumentation set (`auto` or a comma-separated list). */\nexport const INSTRUMENTATIONS_ENV = 'BOFF_OTEL_INSTRUMENTATIONS';\n\n/**\n * The libraries the fleet's traces and dashboards come from: outbound HTTP\n * (`http`, `undici` for `fetch`), Postgres through the Prisma pg adapter,\n * Redis/Valkey clients, GraphQL execution, pino log correlation, the AWS SDK\n * and DataLoader batches.\n */\nexport const DEFAULT_INSTRUMENTATIONS: readonly string[] = [\n 'http',\n 'undici',\n 'pg',\n 'ioredis',\n 'redis',\n 'graphql',\n 'pino',\n 'aws-sdk',\n 'dataloader',\n];\n\n/**\n * Export names that do not follow `<Pascal name>Instrumentation`. Any other\n * package is read through the first export whose name ends in `Instrumentation`.\n */\nconst EXPORT_NAMES: Readonly<Record<string, string>> = {\n http: 'HttpInstrumentation',\n undici: 'UndiciInstrumentation',\n pg: 'PgInstrumentation',\n ioredis: 'IORedisInstrumentation',\n redis: 'RedisInstrumentation',\n graphql: 'GraphQLInstrumentation',\n pino: 'PinoInstrumentation',\n 'aws-sdk': 'AwsInstrumentation',\n dataloader: 'DataloaderInstrumentation',\n};\n\n/** The package that holds the instrumentation called `name` (`pg` → `@opentelemetry/instrumentation-pg`). */\nexport const instrumentationPackage = (name: string): string => `@opentelemetry/instrumentation-${name}`;\n\nexport type InstrumentationPlan =\n { mode: 'auto'; reason: string } | { mode: 'explicit'; names: string[]; reason: string };\n\nconst parseList = (value: string): string[] => [\n ...new Set(\n value\n .split(',')\n .map((entry) => entry.trim().toLowerCase())\n .filter((entry) => entry.length > 0)\n ),\n];\n\nconst isSet = (value: string | undefined): boolean => value !== undefined && value.trim().length > 0;\n\n/** Decides between the full auto-instrumentations set and an explicit list (see the module comment). */\nexport function planInstrumentations(\n env: Readonly<Record<string, string | undefined>> = process.env,\n autoInjected = false\n): InstrumentationPlan {\n const raw = env[INSTRUMENTATIONS_ENV]?.trim() ?? '';\n if (raw.toLowerCase() === 'auto') return { mode: 'auto', reason: `${INSTRUMENTATIONS_ENV}=auto` };\n if (raw.length > 0) {\n const names = parseList(raw);\n if (names.length > 0) return { mode: 'explicit', names, reason: INSTRUMENTATIONS_ENV };\n }\n if (isSet(env['OTEL_NODE_ENABLED_INSTRUMENTATIONS']) || isSet(env['OTEL_NODE_DISABLED_INSTRUMENTATIONS'])) {\n return { mode: 'auto', reason: 'OTEL_NODE_{ENABLED,DISABLED}_INSTRUMENTATIONS is set' };\n }\n if (autoInjected) return { mode: 'auto', reason: 'auto-instrumentations-node was injected' };\n return { mode: 'explicit', names: [...DEFAULT_INSTRUMENTATIONS], reason: 'default list' };\n}\n\ntype InstrumentationClass = new (config?: Record<string, unknown>) => unknown;\n\n/** The instrumentation class a loaded package exports, or undefined when there is none. */\nexport function instrumentationClass(name: string, mod: unknown): InstrumentationClass | undefined {\n if (typeof mod !== 'object' || mod === null) return undefined;\n const exports = mod as Record<string, unknown>;\n const known = EXPORT_NAMES[name];\n const candidate =\n known !== undefined\n ? exports[known]\n : Object.entries(exports).find(\n ([key, value]) => key.endsWith('Instrumentation') && typeof value === 'function'\n )?.[1];\n // A class is a function at runtime; it is only ever called with `new` below.\n return typeof candidate === 'function' ? (candidate as InstrumentationClass) : undefined;\n}\n\nexport interface ExplicitInstrumentations {\n instances: unknown[];\n loaded: string[];\n /** `name: reason` for each instrumentation that could not be loaded or built. */\n missing: string[];\n}\n\n/**\n * Imports and instantiates each named instrumentation. A package that is not\n * installed or does not export an instrumentation is skipped and reported,\n * never fatal.\n */\nexport async function loadExplicitInstrumentations(\n names: readonly string[],\n load: (specifier: string) => Promise<unknown>\n): Promise<ExplicitInstrumentations> {\n const result: ExplicitInstrumentations = { instances: [], loaded: [], missing: [] };\n for (const name of names) {\n try {\n const Instrumentation = instrumentationClass(name, await load(instrumentationPackage(name)));\n if (Instrumentation === undefined) {\n result.missing.push(`${name}: no instrumentation export`);\n continue;\n }\n result.instances.push(new Instrumentation());\n result.loaded.push(name);\n } catch (error) {\n result.missing.push(`${name}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n return result;\n}\n","/**\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';\nimport { loadExplicitInstrumentations, planInstrumentations } from './instrumentations.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/**\n * Module namespaces injected in place of runtime imports (see `OtelSdkConfig.modules`).\n * Single instrumentation packages (`@opentelemetry/instrumentation-pg`) can be\n * injected too; they are used when be-sdk registers its explicit list\n * (`./instrumentations.ts`).\n */\nexport type OtelModules = Partial<Record<OtelPeerPackage | InstrumentationPackage, unknown>>;\n\n/** A single OpenTelemetry instrumentation package. */\nexport type InstrumentationPackage = `@opentelemetry/instrumentation-${string}`;\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 // Instrumentations: an explicit list by default, the full auto set on request\n // or as the fallback (BOFF-16818, see ./instrumentations.ts). All optional.\n let autoInstrumentations: unknown[] | undefined;\n const plan = planInstrumentations(\n process.env,\n cfg.modules?.['@opentelemetry/auto-instrumentations-node'] !== undefined\n );\n if (plan.mode === 'explicit') {\n const explicit = await loadExplicitInstrumentations(plan.names, (specifier) => {\n // instrumentationPackage() only ever builds `@opentelemetry/instrumentation-<name>`.\n const injected = cfg.modules?.[specifier as InstrumentationPackage];\n return injected !== undefined ? Promise.resolve(injected) : importOptionalPeer(specifier);\n });\n if (explicit.instances.length > 0) {\n autoInstrumentations = explicit.instances;\n console.log(`[sdk] instrumentations (${plan.reason}): ${explicit.loaded.join(',')}`);\n if (explicit.missing.length > 0) console.log(`[sdk] instrumentations skipped: ${explicit.missing.join('; ')}`);\n } else {\n console.log(\n `[sdk] none of the explicit instrumentations could be loaded (${explicit.missing.join('; ')}); ` +\n 'falling back to auto-instrumentations-node'\n );\n }\n } else {\n console.log(`[sdk] full auto-instrumentations set (${plan.reason})`);\n }\n if (autoInstrumentations === undefined) {\n try {\n console.log('[sdk] importing @opentelemetry/auto-instrumentations-node...');\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\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,uBAAuB;;;;;;;AAQpC,MAAa,2BAA8C;CACzD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAMA,MAAM,eAAiD;CACrD,MAAM;CACN,QAAQ;CACR,IAAI;CACJ,SAAS;CACT,OAAO;CACP,SAAS;CACT,MAAM;CACN,WAAW;CACX,YAAY;AACd;;AAGA,MAAa,0BAA0B,SAAyB,kCAAkC;AAKlG,MAAM,aAAa,UAA4B,CAC7C,GAAG,IAAI,IACL,MACG,MAAM,GAAG,CAAC,CACV,KAAK,UAAU,MAAM,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAC1C,QAAQ,UAAU,MAAM,SAAS,CAAC,CACvC,CACF;AAEA,MAAM,SAAS,UAAuC,UAAU,UAAa,MAAM,KAAK,CAAC,CAAC,SAAS;;AAGnG,SAAgB,qBACd,MAAoD,QAAQ,KAC5D,eAAe,OACM;CACrB,MAAM,MAAM,iCAAyB,EAAE,KAAK,KAAK;CACjD,IAAI,IAAI,YAAY,MAAM,QAAQ,OAAO;EAAE,MAAM;EAAQ,QAAQ,GAAG,qBAAqB;CAAO;CAChG,IAAI,IAAI,SAAS,GAAG;EAClB,MAAM,QAAQ,U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W,WAAW,GACxB,MAAM;CAER,QAAQ,IAAI,uBAAuB;CAGnC,IAAI;EACF,AAAC,WAAkD,YAAY,MAAM,KAAK,oBAAoB;EAC9F,QAAQ,IAAI,iDAAiD;CAC/D,QAAQ;EACN,QAAQ,IAAI,mDAAmD;CACjE;CAEA,QAAQ,IAAI,wCAAwC;CACpD,OAAO;EACL,UAAU,YAA2B,QAAQ,SAAS;EACtD;EACA;EACA,GAAI,cAAc,SAAS,EAAE,eAAe,cAAc,OAAO,IAAI,CAAC;CACxE;AACF"}
|
|
@@ -6,7 +6,8 @@ interface TelemetryIdGenerator {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function assertTelemetryIdGenerator(candidate: unknown): asserts candidate is TelemetryIdGenerator | undefined;
|
|
8
8
|
type OtelPeerPackage = '@opentelemetry/api' | '@opentelemetry/auto-instrumentations-node' | '@opentelemetry/exporter-metrics-otlp-http' | '@opentelemetry/exporter-trace-otlp-http' | '@opentelemetry/resources' | '@opentelemetry/sdk-metrics' | '@opentelemetry/sdk-node' | '@opentelemetry/sdk-trace-base' | '@opentelemetry/semantic-conventions';
|
|
9
|
-
type OtelModules = Partial<Record<OtelPeerPackage, unknown>>;
|
|
9
|
+
type OtelModules = Partial<Record<OtelPeerPackage | InstrumentationPackage, unknown>>;
|
|
10
|
+
type InstrumentationPackage = `@opentelemetry/instrumentation-${string}`;
|
|
10
11
|
interface PrismaLike {
|
|
11
12
|
$queryRaw: (strings: TemplateStringsArray) => Promise<unknown>;
|
|
12
13
|
}
|
package/dist/telemetry/index.js
CHANGED
|
@@ -352,7 +352,7 @@ async function bootstrapTelemetry(cfg) {
|
|
|
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-7TBR987n.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.1127.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",
|
package/dist/sdk-BkIS_wTK.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,aAA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