@interopio/otel 0.1.19 → 0.1.20

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/index.d.ts CHANGED
@@ -96,7 +96,7 @@ export { Traces, withSpan };
96
96
  export declare const OTEL_PI_KEY = "__interopIOTracePropagationInfo";
97
97
  import NullTracingState from "./traces/nullTracingState";
98
98
  export { NullTracingState };
99
- export { BufferingTracesManager } from "./traces/bufferingTracesManager";
99
+ export { BufferingTracesManager, type ReplayOptions } from "./traces/bufferingTracesManager";
100
100
  export type { RecordedSpan } from "./traces/bufferingTracingState";
101
101
  export type ioInsightsLogsPlugin = {
102
102
  newLogsManager: (logger: IOInsights.Logger, settings: IOInsights.LogsSettings, otelSettings: IOInsights.Settings) => IOInsights.LogsManager;
@@ -113,9 +113,10 @@ export { type InMemoryLogRecordExporter, type InMemoryMetricExporter, type InMem
113
113
  import { registerInsightsPlugin, loadInsightsPlugin } from "./pluginLoader";
114
114
  import { isNode } from "./utils/isNode";
115
115
  import { safeStringify } from "./utils/safe-stringify";
116
- import { getOTELData, flattenOtelAtributes, extractFilteringContextFromArgs, deep_value, withTimeout } from "./utils/otelUtils";
116
+ import { getOTELData, flattenOtelAtributes, extractFilteringContextFromArgs, deep_value, withTimeout, isError } from "./utils/otelUtils";
117
+ export { createExportHeaders, applySsoAuthHeaders, type ExportHeaders } from "./utils/exportHeaders";
117
118
  export { registerInsightsPlugin, loadInsightsPlugin };
118
- export { isNode, safeStringify, flattenOtelAtributes, getOTELData, extractFilteringContextFromArgs, deep_value, withTimeout };
119
+ export { isNode, safeStringify, flattenOtelAtributes, getOTELData, extractFilteringContextFromArgs, deep_value, withTimeout, isError };
119
120
  declare enum SpanStatusCode {
120
121
  /**
121
122
  * The default status.
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.SpanStatusCode = exports.withTimeout = exports.deep_value = exports.extractFilteringContextFromArgs = exports.getOTELData = exports.flattenOtelAtributes = exports.safeStringify = exports.isNode = exports.loadInsightsPlugin = exports.registerInsightsPlugin = exports.Logs = exports.BufferingTracesManager = exports.NullTracingState = exports.OTEL_PI_KEY = exports.withSpan = exports.Traces = exports.MetricsDependencyBuilder = exports.NullMetric = exports.Container = exports.Log4jsWrapper = exports.Builder = void 0;
39
+ exports.SpanStatusCode = exports.isError = exports.withTimeout = exports.deep_value = exports.extractFilteringContextFromArgs = exports.getOTELData = exports.flattenOtelAtributes = exports.safeStringify = exports.isNode = exports.loadInsightsPlugin = exports.registerInsightsPlugin = exports.applySsoAuthHeaders = exports.createExportHeaders = exports.Logs = exports.BufferingTracesManager = exports.NullTracingState = exports.OTEL_PI_KEY = exports.withSpan = exports.Traces = exports.MetricsDependencyBuilder = exports.NullMetric = exports.Container = exports.Log4jsWrapper = exports.Builder = void 0;
40
40
  ;
41
41
  var builder_1 = require("./builder");
42
42
  Object.defineProperty(exports, "Builder", { enumerable: true, get: function () { return builder_1.Builder; } });
@@ -71,6 +71,10 @@ Object.defineProperty(exports, "flattenOtelAtributes", { enumerable: true, get:
71
71
  Object.defineProperty(exports, "extractFilteringContextFromArgs", { enumerable: true, get: function () { return otelUtils_1.extractFilteringContextFromArgs; } });
72
72
  Object.defineProperty(exports, "deep_value", { enumerable: true, get: function () { return otelUtils_1.deep_value; } });
73
73
  Object.defineProperty(exports, "withTimeout", { enumerable: true, get: function () { return otelUtils_1.withTimeout; } });
74
+ Object.defineProperty(exports, "isError", { enumerable: true, get: function () { return otelUtils_1.isError; } });
75
+ var exportHeaders_1 = require("./utils/exportHeaders");
76
+ Object.defineProperty(exports, "createExportHeaders", { enumerable: true, get: function () { return exportHeaders_1.createExportHeaders; } });
77
+ Object.defineProperty(exports, "applySsoAuthHeaders", { enumerable: true, get: function () { return exportHeaders_1.applySsoAuthHeaders; } });
74
78
  if (typeof Promise !== "undefined") {
75
79
  Promise.allSettled = Promise.allSettled || ((promises) => Promise.all(promises.map((p) => p
76
80
  .then((value) => ({
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASC,CAAC;AAKF,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,wDAAuD;AAA9C,8GAAA,aAAa,OAAA;AACtB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AA0BlB,uCAA4C;AAAnC,kGAAA,UAAU,OAAA;AACnB,+EAA8E;AAArE,oIAAA,wBAAwB,OAAA;AAuEjC,0DAAoD;AAC3C,iBADF,gBAAM,CACE;AAAE,yFADC,iBAAQ,OACD;AACZ,QAAA,WAAW,GAAG,iCAAiC,CAAC;AAC7D,iFAAyD;AAChD,2BADF,0BAAgB,CACE;AACzB,0EAAyE;AAAhE,gIAAA,sBAAsB,OAAA;AAY/B,oCAAmC;AAA1B,4FAAA,IAAI,OAAA;AAUb,iDAA4E;AAInE,uGAJA,qCAAsB,OAIA;AAAE,mGAJA,iCAAkB,OAIA;AAHnD,2CAAwC;AAI/B,uFAJA,eAAM,OAIA;AAHf,2DAAuD;AAGtC,8FAHR,8BAAa,OAGQ;AAF9B,iDAAgI;AAE1E,4FAF7C,uBAAW,OAE6C;AAAjC,qGAFV,gCAAoB,OAEU;AAAe,gHAFvB,2CAA+B,OAEuB;AAAE,2FAFvB,sBAAU,OAEuB;AAAE,4FAFvB,uBAAW,OAEuB;AAE3H,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;IACnC,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CACxE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;SACrB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,2FAHvB,sBAAU,OAGuB;AAAE,4FAHvB,uBAAW,OAGuB;AAAE,wFAHvB,mBAAO,OAGuB;AAFpI,uDAAqG;AAA5F,oHAAA,mBAAmB,OAAA;AAAE,oHAAA,mBAAmB,OAAA;AAIjD,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;IACnC,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CACxE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;SACrB,IAAI,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC;QACnB,MAAM,EAAE,WAAW;QACnB,KAAK;KACR,CAAC,CAAC;SACF,KAAK,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,CAAC;QACrB,MAAM,EAAE,UAAU;QAClB,MAAM;KACT,CAAC,CAAC,CACN,CACF,CAAC,CAAC;AACL,CAAC;AACD,IAAK,cAcJ;AAdD,WAAK,cAAc;IACjB;;OAEG;IACH,qDAAS,CAAA;IACT;;;OAGG;IACH,+CAAM,CAAA;IACN;;OAEG;IACH,qDAAS,CAAA;AACX,CAAC,EAdI,cAAc,8BAAd,cAAc,QAclB"}
@@ -1,6 +1,28 @@
1
1
  import { IOInsights } from "../../insights";
2
2
  import { NullManager } from "../nullManager";
3
3
  type PropagationInfo = IOInsights.PropagationInfo;
4
+ /**
5
+ * What is active while a span's callback - and everything it awaits - runs: the node new spans
6
+ * get nested under, and the tracing state of the span itself. They differ for spans dropped by
7
+ * the capacity guard: those are not recorded, so their descendants nest under the nearest
8
+ * recorded ancestor, while Traces.currentTracingState still has to be the dropped span's own.
9
+ */
10
+ export interface ReplayOptions {
11
+ /**
12
+ * What to do with spans that are still in flight - their callback returned a promise that has
13
+ * not settled yet - when the buffer gets replayed.
14
+ *
15
+ * `false` (the default): they are published as ending at replay time, with an UNSET status.
16
+ * Right when the replay happens because the process is going down: a span that is left open
17
+ * is never exported.
18
+ *
19
+ * `true`: the real span is kept open until the buffered span's callback settles, so it gets
20
+ * its true duration and outcome - OK, or ERROR with the exception, exactly as if it had been
21
+ * started on the real manager. Whatever is recorded on the buffered tracing state in the
22
+ * meantime (addData, events, exceptions, the status) goes to the real span.
23
+ */
24
+ keepOpen?: boolean;
25
+ }
4
26
  /**
5
27
  * A stand-in TracesManager used **before** the OTEL SDK is initialized.
6
28
  *
@@ -21,11 +43,33 @@ export declare class BufferingTracesManager extends NullManager<IOInsights.Trace
21
43
  private readonly roots;
22
44
  private readonly piIndex;
23
45
  private readonly als;
24
- private syncParent;
46
+ private syncScope;
25
47
  private spanCount;
26
48
  private dropped;
27
49
  private _currentTracingState;
50
+ private replayDone;
28
51
  constructor(logger?: IOInsights.Logger | undefined, maxSpans?: number);
52
+ /**
53
+ * Makes the buffer the process-wide traces manager (globalThis.ioInsightsInternals.traces) -
54
+ * what Traces.instance and every Container's `traces` resolve to, whichever copy of this
55
+ * package they come from, and what a builder that is not `definitiveInstance` hands out
56
+ * instead of building a manager of its own. So whoever initializes io.Insights while the
57
+ * buffer is in charge (another library in the same process) shares the buffer, rather than
58
+ * taking the spans away from it.
59
+ *
60
+ * The manager the buffer is eventually replayed into has to be built with `definitiveInstance`:
61
+ * that is what lets it replace the buffer. Leaves an already registered manager alone.
62
+ *
63
+ * @returns whether the buffer is the registered manager now
64
+ */
65
+ registerGlobal(): boolean;
66
+ /**
67
+ * Steps down as the process-wide traces manager, if the buffer still is it. replayInto() does
68
+ * this on its own; call it earlier - right before io.Insights gets initialized - when that
69
+ * initialization may well come out disabled: a disabled build registers nothing, and would
70
+ * find (and keep) the buffer.
71
+ */
72
+ releaseGlobal(): void;
29
73
  get settings(): IOInsights.TracesSettings;
30
74
  set settings(_value: IOInsights.TracesSettings);
31
75
  get currentTracingState(): IOInsights.TracingState | null;
@@ -39,7 +83,8 @@ export declare class BufferingTracesManager extends NullManager<IOInsights.Trace
39
83
  * callback returns a thenable.
40
84
  */
41
85
  private execute;
42
- private runInChild;
86
+ private runInScope;
87
+ private currentScope;
43
88
  private currentParent;
44
89
  private resolveParent;
45
90
  private extractPropagationInfo;
@@ -50,9 +95,39 @@ export declare class BufferingTracesManager extends NullManager<IOInsights.Trace
50
95
  * @param parentPI Optional propagation info to nest all buffered top-level
51
96
  * spans under (e.g. the app's real startup root span). A buffered root that
52
97
  * carried its own external propagation info keeps it instead.
98
+ * @param options see ReplayOptions
53
99
  */
54
- replayInto(manager: IOInsights.TracesManager, parentPI?: PropagationInfo | null): void;
100
+ replayInto(manager: IOInsights.TracesManager, parentPI?: PropagationInfo | null, options?: ReplayOptions): void;
55
101
  private replayNode;
102
+ /**
103
+ * The propagation info new spans should nest under, for code that is running inside (the async
104
+ * continuation of) a buffered span which has since been replayed: that of the real span it was
105
+ * replayed as. Null anywhere else - outside of a buffered span, or before the replay.
106
+ */
107
+ getActivePropagationInfo(): PropagationInfo | null;
108
+ /**
109
+ * Hands the nesting of the buffered spans over to the real TracesManager.
110
+ *
111
+ * A real manager using an OTEL context manager resolves the parent of a new span from the
112
+ * active OTEL context. Code that started under a buffered span - and is still running when the
113
+ * real manager takes over - has none: the buffer tracks nesting on its own. Its spans would
114
+ * become roots of new traces, or not be created at all when they cannot be roots. This plugs
115
+ * getActivePropagationInfo() into the real manager's last-resort `defaults.getPropagationInfo`
116
+ * hook, which is only consulted when nothing else provides a parent - so such code keeps
117
+ * nesting under the span it started in.
118
+ *
119
+ * The bridge is asked before a hook that is already installed: it only ever answers for code
120
+ * running inside a replayed span, which makes it the more specific of the two - the library's
121
+ * own startup trace, for one, installs a hook that answers with the generic startup root for
122
+ * every parentless span. Everywhere else the existing hook answers as before.
123
+ *
124
+ * Call it after replayInto(), and call the returned function once the buffered work is over
125
+ * (e.g. when the startup completes): a timer loop that started under a buffered span would
126
+ * otherwise keep nesting under it forever.
127
+ *
128
+ * @returns a function that removes the bridge
129
+ */
130
+ bridgePropagation(manager: IOInsights.TracesManager): () => void;
56
131
  setFilterConfig(_filters: IOInsights.SpanFilter[]): void;
57
132
  get startupTraceFinished(): (() => void);
58
133
  get userJourneyMarker(): IOInsights.MarkerSpanCallback;
@@ -47,6 +47,7 @@ const nullManager_1 = require("../nullManager");
47
47
  const bufferingTracingState_1 = __importStar(require("./bufferingTracingState"));
48
48
  // SpanStatusCode is declared in the package index; use the raw numeric values
49
49
  // here to avoid a circular import at module-evaluation time (index -> this file).
50
+ const STATUS_UNSET = 0; // SpanStatusCode.UNSET
50
51
  const STATUS_OK = 1; // SpanStatusCode.OK
51
52
  const STATUS_ERROR = 2; // SpanStatusCode.ERROR
52
53
  // AsyncLocalStorage gives us automatic parent/child nesting across `await`
@@ -86,8 +87,43 @@ class BufferingTracesManager extends nullManager_1.NullManager {
86
87
  this.spanCount = 0;
87
88
  this.dropped = 0;
88
89
  this._currentTracingState = null;
90
+ // set once the buffer has been replayed: from then on nothing is recorded anymore
91
+ this.replayDone = false;
89
92
  this.started = true;
90
93
  }
94
+ /**
95
+ * Makes the buffer the process-wide traces manager (globalThis.ioInsightsInternals.traces) -
96
+ * what Traces.instance and every Container's `traces` resolve to, whichever copy of this
97
+ * package they come from, and what a builder that is not `definitiveInstance` hands out
98
+ * instead of building a manager of its own. So whoever initializes io.Insights while the
99
+ * buffer is in charge (another library in the same process) shares the buffer, rather than
100
+ * taking the spans away from it.
101
+ *
102
+ * The manager the buffer is eventually replayed into has to be built with `definitiveInstance`:
103
+ * that is what lets it replace the buffer. Leaves an already registered manager alone.
104
+ *
105
+ * @returns whether the buffer is the registered manager now
106
+ */
107
+ registerGlobal() {
108
+ var _a;
109
+ globalThis.ioInsightsInternals = (_a = globalThis.ioInsightsInternals) !== null && _a !== void 0 ? _a : {};
110
+ if (!globalThis.ioInsightsInternals.traces) {
111
+ globalThis.ioInsightsInternals.traces = this;
112
+ }
113
+ return globalThis.ioInsightsInternals.traces === this;
114
+ }
115
+ /**
116
+ * Steps down as the process-wide traces manager, if the buffer still is it. replayInto() does
117
+ * this on its own; call it earlier - right before io.Insights gets initialized - when that
118
+ * initialization may well come out disabled: a disabled build registers nothing, and would
119
+ * find (and keep) the buffer.
120
+ */
121
+ releaseGlobal() {
122
+ var _a;
123
+ if (((_a = globalThis.ioInsightsInternals) === null || _a === void 0 ? void 0 : _a.traces) === this) {
124
+ delete globalThis.ioInsightsInternals.traces;
125
+ }
126
+ }
91
127
  get settings() {
92
128
  // Report enabled so instrumented code doesn't short-circuit its data
93
129
  // gathering while we're buffering.
@@ -97,7 +133,12 @@ class BufferingTracesManager extends nullManager_1.NullManager {
97
133
  // no-op: buffering has no real settings
98
134
  }
99
135
  get currentTracingState() {
100
- return this._currentTracingState;
136
+ var _a, _b;
137
+ // The scope follows the span's callback across `await`s (AsyncLocalStorage), the same way
138
+ // the real manager behaves with an OTEL context manager. The plain field is what is left
139
+ // without AsyncLocalStorage (a browser bundle), and what an explicit assignment sets: it is
140
+ // only reliable until the callback's first `await`.
141
+ return (_b = (_a = this.currentScope()) === null || _a === void 0 ? void 0 : _a.ts) !== null && _b !== void 0 ? _b : this._currentTracingState;
101
142
  }
102
143
  set currentTracingState(ts) {
103
144
  this._currentTracingState = ts;
@@ -114,6 +155,7 @@ class BufferingTracesManager extends nullManager_1.NullManager {
114
155
  });
115
156
  }
116
157
  withSpan(source, filteringContextOrCallback, propagationInfoOrCallback, optionsOrCallback, callback) {
158
+ var _a;
117
159
  const actualCallback = typeof filteringContextOrCallback === "function" ? filteringContextOrCallback
118
160
  : typeof propagationInfoOrCallback === "function" ? propagationInfoOrCallback
119
161
  : typeof optionsOrCallback === "function" ? optionsOrCallback
@@ -137,6 +179,11 @@ class BufferingTracesManager extends nullManager_1.NullManager {
137
179
  this.dropped++;
138
180
  return this.execute(ts, node, actualCallback, false);
139
181
  }
182
+ // The buffer has been replayed already - a span recorded now would never be published, only
183
+ // held on to. Keep executing callbacks for whoever still holds a reference to this manager.
184
+ if (this.replayDone) {
185
+ return this.execute(ts, node, actualCallback, false);
186
+ }
140
187
  this.spanCount++;
141
188
  const parent = this.resolveParent(explicitPI);
142
189
  if (parent) {
@@ -145,7 +192,7 @@ class BufferingTracesManager extends nullManager_1.NullManager {
145
192
  else {
146
193
  this.roots.push(node);
147
194
  }
148
- if (node.syntheticPropagationInfo.traceparent) {
195
+ if ((_a = node.syntheticPropagationInfo) === null || _a === void 0 ? void 0 : _a.traceparent) {
149
196
  this.piIndex.set(node.syntheticPropagationInfo.traceparent, node);
150
197
  }
151
198
  return this.execute(ts, node, actualCallback, true);
@@ -157,14 +204,17 @@ class BufferingTracesManager extends nullManager_1.NullManager {
157
204
  */
158
205
  execute(ts, node, actualCallback, record) {
159
206
  const finalize = () => {
207
+ node.pending = undefined;
160
208
  if (record && !node.endTime) {
161
209
  node.endTime = new Date();
162
210
  }
163
211
  };
164
212
  const onError = (err) => {
165
- if (record) {
213
+ // once replayed, the outcome is either the real span's business (kept open - the real
214
+ // manager sees the same rejection) or of no use to anyone (published as ended)
215
+ if (record && !node.replayed) {
166
216
  node.status = { code: STATUS_ERROR, message: typeof err === "string" ? err : err === null || err === void 0 ? void 0 : err.message };
167
- node.exceptions.push({ exception: err });
217
+ node.exceptions.push({ exception: err, time: new Date() });
168
218
  }
169
219
  finalize();
170
220
  };
@@ -174,9 +224,9 @@ class BufferingTracesManager extends nullManager_1.NullManager {
174
224
  let threw = false;
175
225
  let errObj;
176
226
  try {
177
- // Only open a nesting scope for recorded spans, so descendants of a dropped
178
- // span don't get parented to a node that will never be replayed.
179
- result = record ? this.runInChild(node, () => actualCallback(ts)) : actualCallback(ts);
227
+ // Descendants of a dropped span must not get parented to a node that will never be
228
+ // replayed: its scope keeps the nearest recorded ancestor as the nesting node.
229
+ result = this.runInScope({ node: record ? node : this.currentParent(), ts }, () => actualCallback(ts));
180
230
  }
181
231
  catch (err) {
182
232
  threw = true;
@@ -190,26 +240,33 @@ class BufferingTracesManager extends nullManager_1.NullManager {
190
240
  throw errObj;
191
241
  }
192
242
  if (result && typeof result.then === "function") {
243
+ if (record) {
244
+ node.pending = result;
245
+ }
193
246
  return result.then((r) => { finalize(); return r; }, (err) => { onError(err); throw err; });
194
247
  }
195
248
  finalize();
196
249
  return result;
197
250
  }
198
- runInChild(node, fn) {
251
+ runInScope(scope, fn) {
199
252
  if (this.als) {
200
- return this.als.run(node, fn);
253
+ return this.als.run(scope, fn);
201
254
  }
202
- const prev = this.syncParent;
203
- this.syncParent = node;
255
+ const prev = this.syncScope;
256
+ this.syncScope = scope;
204
257
  try {
205
258
  return fn();
206
259
  }
207
260
  finally {
208
- this.syncParent = prev;
261
+ this.syncScope = prev;
209
262
  }
210
263
  }
264
+ currentScope() {
265
+ return this.als ? this.als.getStore() : this.syncScope;
266
+ }
211
267
  currentParent() {
212
- return this.als ? this.als.getStore() : this.syncParent;
268
+ var _a;
269
+ return (_a = this.currentScope()) === null || _a === void 0 ? void 0 : _a.node;
213
270
  }
214
271
  resolveParent(explicitPI) {
215
272
  if (explicitPI === null || explicitPI === void 0 ? void 0 : explicitPI.traceparent) {
@@ -241,24 +298,40 @@ class BufferingTracesManager extends nullManager_1.NullManager {
241
298
  * @param parentPI Optional propagation info to nest all buffered top-level
242
299
  * spans under (e.g. the app's real startup root span). A buffered root that
243
300
  * carried its own external propagation info keeps it instead.
301
+ * @param options see ReplayOptions
244
302
  */
245
- replayInto(manager, parentPI = null) {
303
+ replayInto(manager, parentPI = null, options) {
246
304
  var _a, _b, _c;
247
- for (const root of this.roots) {
248
- this.replayNode(manager, root, (_a = root.explicitPropagationInfo) !== null && _a !== void 0 ? _a : parentPI);
305
+ this.replayDone = true;
306
+ // from here on the buffer records nothing - it must not be what Traces.instance resolves to
307
+ this.releaseGlobal();
308
+ // The buffer is handed over exactly once: it is emptied up front, so a second replayInto()
309
+ // has nothing to replay - it would otherwise publish every span again.
310
+ const roots = this.roots.splice(0, this.roots.length);
311
+ this.piIndex.clear();
312
+ if (manager === this) {
313
+ // there is no real manager (io.Insights came out disabled, or failed to initialize):
314
+ // nothing to replay into - the spans are let go of
315
+ this.dropped = 0;
316
+ return;
317
+ }
318
+ const keepOpen = (options === null || options === void 0 ? void 0 : options.keepOpen) === true;
319
+ for (const root of roots) {
320
+ this.replayNode(manager, root, (_a = root.explicitPropagationInfo) !== null && _a !== void 0 ? _a : parentPI, keepOpen);
249
321
  }
250
322
  if (this.dropped > 0) {
251
323
  (_c = (_b = this.logger) === null || _b === void 0 ? void 0 : _b.warn) === null || _c === void 0 ? void 0 : _c.call(_b, `BufferingTracesManager: ${this.dropped} startup span(s) dropped after reaching the buffer cap of ${this.maxSpans}`);
324
+ this.dropped = 0;
252
325
  }
253
326
  }
254
- replayNode(manager, node, parentPI) {
255
- var _a;
256
- const options = Object.assign(Object.assign({}, node.options), { otelSpanOptions: Object.assign(Object.assign({}, (_a = node.options) === null || _a === void 0 ? void 0 : _a.otelSpanOptions), { startTime: node.startTime }),
327
+ replayNode(manager, node, parentPI, keepOpen) {
328
+ var _a, _b, _c, _d;
329
+ const options = Object.assign(Object.assign({}, node.options), { otelSpanOptions: Object.assign(Object.assign({}, (_a = node.options) === null || _a === void 0 ? void 0 : _a.otelSpanOptions), { startTime: (_d = (_c = (_b = node.options) === null || _b === void 0 ? void 0 : _b.otelSpanOptions) === null || _c === void 0 ? void 0 : _c.startTime) !== null && _d !== void 0 ? _d : node.startTime }),
257
330
  // We restore the recorded status explicitly below, so don't let the real
258
331
  // manager stamp OK on the (already-resolved) callback.
259
332
  autoSetSuccessStatus: false });
260
- manager.withSpan(node.source, node.filteringContext, parentPI, options, (ts) => {
261
- var _a, _b;
333
+ const replayed = manager.withSpan(node.source, node.filteringContext, parentPI, options, (ts) => {
334
+ var _a, _b, _c;
262
335
  if (node.updatedName) {
263
336
  ts.updateName(node.updatedName);
264
337
  }
@@ -271,13 +344,109 @@ class BufferingTracesManager extends nullManager_1.NullManager {
271
344
  for (const x of node.exceptions) {
272
345
  ts.recordException(x.exception, x.time);
273
346
  }
274
- ts.status = (_a = node.status) !== null && _a !== void 0 ? _a : { code: STATUS_OK };
275
- const childPI = ts.getPropagationInfo();
347
+ // The buffer only records a status on failure (or when one is set explicitly), so a
348
+ // finished span without one has succeeded. A span that is still open at replay time has
349
+ // not: it is published as ending now, but whatever it was doing is still in flight - or
350
+ // was cut short, when the replay happens because the platform is going down.
351
+ ts.status = (_a = node.status) !== null && _a !== void 0 ? _a : { code: node.endTime ? STATUS_OK : STATUS_UNSET };
352
+ // the real span may not exist (e.g. disabled by a filter): then whatever nests under
353
+ // this node nests under its nearest ancestor that does
354
+ const childPI = (_b = ts.getPropagationInfo()) !== null && _b !== void 0 ? _b : parentPI;
276
355
  for (const child of node.children) {
277
- this.replayNode(manager, child, childPI);
356
+ this.replayNode(manager, child, childPI, keepOpen);
357
+ }
358
+ // ensure future spans get nested under the real span - see getActivePropagationInfo()
359
+ // and BufferingTracingState.getPropagationInfo()
360
+ node.replayed = true;
361
+ node.replayedPropagationInfo = childPI;
362
+ // Let go of everything that has just been published. A node can stay reachable for as
363
+ // long as the code that ran under its span does (it is that code's AsyncLocalStorage
364
+ // store - think of a timer loop started during startup), and it would keep its whole
365
+ // subtree of recorded spans and their data alive with it. `replayed` and
366
+ // `replayedPropagationInfo` are all that is needed from here on.
367
+ node.children = [];
368
+ node.events = [];
369
+ node.addedData = [];
370
+ node.exceptions = [];
371
+ const pending = node.pending;
372
+ node.pending = undefined;
373
+ if (keepOpen && !node.endTime && pending) {
374
+ // Still in flight: hand the real manager the very promise the span is waiting on. It
375
+ // keeps a span open for as long as its callback's promise is pending, ends it when that
376
+ // settles, and on a rejection marks it ERROR and records the exception - the same way
377
+ // it would have, had the span been started on it.
378
+ node.liveTs = ts;
379
+ return Promise.resolve(pending).then(() => {
380
+ var _a, _b;
381
+ // the real manager leaves the status of async spans alone
382
+ if (((_b = (_a = ts.status) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : STATUS_UNSET) === STATUS_UNSET) {
383
+ ts.status = { code: STATUS_OK };
384
+ }
385
+ })
386
+ .finally(() => { node.liveTs = undefined; });
278
387
  }
279
- void ts.endSpan((_b = node.endTime) !== null && _b !== void 0 ? _b : new Date());
388
+ void ts.endSpan((_c = node.endTime) !== null && _c !== void 0 ? _c : new Date());
389
+ return undefined;
280
390
  });
391
+ // The rejection of a span kept open belongs to whoever awaits the original promise - the
392
+ // real manager re-throws it on its own chain, which nobody else will ever handle.
393
+ if (replayed && typeof replayed.then === "function") {
394
+ replayed.then(undefined, () => undefined);
395
+ }
396
+ }
397
+ /**
398
+ * The propagation info new spans should nest under, for code that is running inside (the async
399
+ * continuation of) a buffered span which has since been replayed: that of the real span it was
400
+ * replayed as. Null anywhere else - outside of a buffered span, or before the replay.
401
+ */
402
+ getActivePropagationInfo() {
403
+ var _a;
404
+ const node = this.currentParent();
405
+ return (node === null || node === void 0 ? void 0 : node.replayed) ? (_a = node.replayedPropagationInfo) !== null && _a !== void 0 ? _a : null : null;
406
+ }
407
+ /**
408
+ * Hands the nesting of the buffered spans over to the real TracesManager.
409
+ *
410
+ * A real manager using an OTEL context manager resolves the parent of a new span from the
411
+ * active OTEL context. Code that started under a buffered span - and is still running when the
412
+ * real manager takes over - has none: the buffer tracks nesting on its own. Its spans would
413
+ * become roots of new traces, or not be created at all when they cannot be roots. This plugs
414
+ * getActivePropagationInfo() into the real manager's last-resort `defaults.getPropagationInfo`
415
+ * hook, which is only consulted when nothing else provides a parent - so such code keeps
416
+ * nesting under the span it started in.
417
+ *
418
+ * The bridge is asked before a hook that is already installed: it only ever answers for code
419
+ * running inside a replayed span, which makes it the more specific of the two - the library's
420
+ * own startup trace, for one, installs a hook that answers with the generic startup root for
421
+ * every parentless span. Everywhere else the existing hook answers as before.
422
+ *
423
+ * Call it after replayInto(), and call the returned function once the buffered work is over
424
+ * (e.g. when the startup completes): a timer loop that started under a buffered span would
425
+ * otherwise keep nesting under it forever.
426
+ *
427
+ * @returns a function that removes the bridge
428
+ */
429
+ bridgePropagation(manager) {
430
+ const settings = manager.settings;
431
+ if (!settings) {
432
+ return () => { };
433
+ }
434
+ const previousDefaults = settings.defaults;
435
+ const previous = previousDefaults === null || previousDefaults === void 0 ? void 0 : previousDefaults.getPropagationInfo;
436
+ let active = true;
437
+ const bridged = (source, fullFilteringContext) => {
438
+ var _a, _b;
439
+ return (_b = (_a = (active ? this.getActivePropagationInfo() : null)) !== null && _a !== void 0 ? _a : previous === null || previous === void 0 ? void 0 : previous(source, fullFilteringContext)) !== null && _b !== void 0 ? _b : null;
440
+ };
441
+ settings.defaults = Object.assign(Object.assign({}, previousDefaults), { getPropagationInfo: bridged });
442
+ return () => {
443
+ var _a;
444
+ active = false;
445
+ // put the previous hook back, unless someone has replaced ours in the meantime
446
+ if (((_a = settings.defaults) === null || _a === void 0 ? void 0 : _a.getPropagationInfo) === bridged) {
447
+ settings.defaults = Object.assign(Object.assign({}, settings.defaults), { getPropagationInfo: previous });
448
+ }
449
+ };
281
450
  }
282
451
  setFilterConfig(_filters) {
283
452
  // no-op while buffering
@@ -1 +1 @@
1
- {"version":3,"file":"bufferingTracesManager.js","sourceRoot":"","sources":["../../src/traces/bufferingTracesManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,gDAA6C;AAC7C,iFAAuG;AAIvG,8EAA8E;AAC9E,kFAAkF;AAClF,MAAM,SAAS,GAAG,CAAQ,CAAC,CAAC,oBAAoB;AAChD,MAAM,YAAY,GAAG,CAAQ,CAAC,CAAC,uBAAuB;AAEtD,2EAA2E;AAC3E,gFAAgF;AAChF,gFAAgF;AAChF,qDAAqD;AACrD,IAAI,qBAAkD,CAAC;AACvD,IAAI,CAAC;IACH,qGAAqG;IACrG,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,iBAAiB,CAAC;AACnE,CAAC;AAAC,WAAM,CAAC;IACP,qBAAqB,GAAG,SAAS,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAa,sBAAuB,SAAQ,yBAAsC;IAUhF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self-consistent propagation info so code that reads/injects
34
34
  * propagation during startup keeps working. It does NOT correspond to a real
35
35
  * OTEL trace; nesting is reconstructed from the recorded tree at replay time.
36
+ *
37
+ * It therefore means something inside this process only - see createSyntheticPropagationInfo().
36
38
  */
37
39
  syntheticPropagationInfo: IOInsights.PropagationInfo;
40
+ /**
41
+ * The promise returned by the span's callback, for as long as it has not settled: what a span
42
+ * that is still in flight at replay time can be kept open on. See ReplayOptions.keepOpen.
43
+ */
44
+ pending?: PromiseLike<unknown>;
45
+ /**
46
+ * The tracing state of the real span an in-flight span was replayed as and kept open on:
47
+ * whatever is recorded on the buffered tracing state from then on goes straight to it.
48
+ */
49
+ liveTs?: IOInsights.TracingState;
50
+ /** Set once the span has been replayed into the real TracesManager. */
51
+ replayed?: boolean;
52
+ /**
53
+ * The propagation info of the real span this one was replayed as - or, when that span was not
54
+ * created (e.g. disabled by a filter), of its nearest ancestor that was. Null when there is no
55
+ * real span to nest under at all. Only meaningful once `replayed` is set.
56
+ */
57
+ replayedPropagationInfo?: IOInsights.PropagationInfo | null;
38
58
  }
39
59
  /**
40
60
  * Creates a fresh {@link RecordedSpan} with a synthetic W3C traceparent.
@@ -69,6 +89,6 @@ export default class BufferingTracingState implements IOInsights.TracingState {
69
89
  updateName(name: string): this;
70
90
  spanContext(): undefined;
71
91
  addData(level: IOInsights.SpanVerbosity | keyof typeof IOInsights.SpanVerbosity, data: object | (() => object)): void;
72
- getPropagationInfo(): IOInsights.PropagationInfo;
92
+ getPropagationInfo(): IOInsights.PropagationInfo | null;
73
93
  injectPropagationInfo(carrier: IOInsights.PropagationInfoCarrier): void;
74
94
  }