@pristine-ts/telemetry 2.0.3 → 2.0.4
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/lib/cjs/enums/span-keyname.enum.js +2 -30
- package/dist/lib/cjs/enums/span-keyname.enum.js.map +1 -1
- package/dist/lib/cjs/managers/tracing.manager.js +171 -42
- package/dist/lib/cjs/managers/tracing.manager.js.map +1 -1
- package/dist/lib/cjs/models/models.js +1 -0
- package/dist/lib/cjs/models/models.js.map +1 -1
- package/dist/lib/cjs/models/span-event.model.js +6 -0
- package/dist/lib/cjs/models/span-event.model.js.map +1 -0
- package/dist/lib/cjs/models/span.model.js +2 -68
- package/dist/lib/cjs/models/span.model.js.map +1 -1
- package/dist/lib/cjs/models/trace.model.js +2 -35
- package/dist/lib/cjs/models/trace.model.js.map +1 -1
- package/dist/lib/cjs/telemetry.module.js +0 -1
- package/dist/lib/cjs/telemetry.module.js.map +1 -1
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/lib/cjs/utils/span-runner.js +3 -108
- package/dist/lib/cjs/utils/span-runner.js.map +1 -1
- package/dist/lib/esm/enums/span-keyname.enum.js +1 -30
- package/dist/lib/esm/enums/span-keyname.enum.js.map +1 -1
- package/dist/lib/esm/managers/tracing.manager.js +171 -42
- package/dist/lib/esm/managers/tracing.manager.js.map +1 -1
- package/dist/lib/esm/models/models.js +1 -0
- package/dist/lib/esm/models/models.js.map +1 -1
- package/dist/lib/esm/models/span-event.model.js +2 -0
- package/dist/lib/esm/models/span-event.model.js.map +1 -0
- package/dist/lib/esm/models/span.model.js +1 -67
- package/dist/lib/esm/models/span.model.js.map +1 -1
- package/dist/lib/esm/models/trace.model.js +1 -34
- package/dist/lib/esm/models/trace.model.js.map +1 -1
- package/dist/lib/esm/telemetry.module.js +0 -1
- package/dist/lib/esm/telemetry.module.js.map +1 -1
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/lib/esm/utils/span-runner.js +1 -107
- package/dist/lib/esm/utils/span-runner.js.map +1 -1
- package/dist/types/enums/span-keyname.enum.d.ts +1 -29
- package/dist/types/interfaces/tracing-manager.interface.d.ts +1 -50
- package/dist/types/managers/tracing.manager.d.ts +71 -13
- package/dist/types/models/models.d.ts +1 -0
- package/dist/types/models/span-event.model.d.ts +1 -0
- package/dist/types/models/span.model.d.ts +1 -73
- package/dist/types/models/trace.model.d.ts +1 -44
- package/dist/types/telemetry.module.d.ts +0 -1
- package/dist/types/utils/span-runner.d.ts +1 -55
- package/package.json +4 -4
- package/dist/lib/cjs/decorators/decorators.js +0 -18
- package/dist/lib/cjs/decorators/decorators.js.map +0 -1
- package/dist/lib/cjs/decorators/traced.decorator.js +0 -60
- package/dist/lib/cjs/decorators/traced.decorator.js.map +0 -1
- package/dist/lib/esm/decorators/decorators.js +0 -2
- package/dist/lib/esm/decorators/decorators.js.map +0 -1
- package/dist/lib/esm/decorators/traced.decorator.js +0 -57
- package/dist/lib/esm/decorators/traced.decorator.js.map +0 -1
- package/dist/types/decorators/decorators.d.ts +0 -1
- package/dist/types/decorators/traced.decorator.d.ts +0 -35
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* This enum is for the different span names that are integrated in Pristine.
|
|
3
|
-
*/
|
|
4
|
-
export var SpanKeynameEnum;
|
|
5
|
-
(function (SpanKeynameEnum) {
|
|
6
|
-
SpanKeynameEnum["ChildContainerCreation"] = "child.container.creation";
|
|
7
|
-
SpanKeynameEnum["ChildContainerRegistration"] = "child.container.registration";
|
|
8
|
-
SpanKeynameEnum["ConfigurationInitialization"] = "configuration.initialization";
|
|
9
|
-
SpanKeynameEnum["ErrorResponseInterceptors"] = "error.response.interceptors";
|
|
10
|
-
SpanKeynameEnum["EventDispatcherResolver"] = "event.dispatcher.resolver";
|
|
11
|
-
SpanKeynameEnum["EventExecution"] = "event.execution";
|
|
12
|
-
SpanKeynameEnum["EventInitialization"] = "event.initialization";
|
|
13
|
-
SpanKeynameEnum["EventPreMappingInterception"] = "event.pre-mapping.interception";
|
|
14
|
-
SpanKeynameEnum["EventPostMappingInterception"] = "event.post-mapping.interception";
|
|
15
|
-
SpanKeynameEnum["EventPreResponseMappingInterception"] = "event.pre-response-mapping.interception";
|
|
16
|
-
SpanKeynameEnum["EventPostResponseMappingInterception"] = "event.post-response-mapping.interception";
|
|
17
|
-
SpanKeynameEnum["EventMapping"] = "event.mapping";
|
|
18
|
-
SpanKeynameEnum["KernelInitialization"] = "kernel.initialization";
|
|
19
|
-
SpanKeynameEnum["ModuleInitialization"] = "module.initialization";
|
|
20
|
-
SpanKeynameEnum["ModuleInitializationImportModules"] = "module.initialization.import.modules";
|
|
21
|
-
SpanKeynameEnum["RequestExecution"] = "request.execution";
|
|
22
|
-
SpanKeynameEnum["RequestInterceptors"] = "request.interceptors";
|
|
23
|
-
SpanKeynameEnum["ResponseInterceptors"] = "response.interceptors";
|
|
24
|
-
SpanKeynameEnum["RootExecution"] = "root.execution";
|
|
25
|
-
SpanKeynameEnum["RouterControllerResolver"] = "router.controller.resolver";
|
|
26
|
-
SpanKeynameEnum["RouterFindMethodRouterNode"] = "router.find.method.router.node";
|
|
27
|
-
SpanKeynameEnum["RouterRequestAuthentication"] = "router.request.authentication";
|
|
28
|
-
SpanKeynameEnum["RouterRequestExecution"] = "router.request.execution";
|
|
29
|
-
SpanKeynameEnum["RouterSetup"] = "router.setup";
|
|
30
|
-
})(SpanKeynameEnum || (SpanKeynameEnum = {}));
|
|
1
|
+
export { SpanKeynameEnum } from "@pristine-ts/common";
|
|
31
2
|
//# sourceMappingURL=span-keyname.enum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"span-keyname.enum.js","sourceRoot":"","sources":["../../../../src/enums/span-keyname.enum.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"span-keyname.enum.js","sourceRoot":"","sources":["../../../../src/enums/span-keyname.enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAC"}
|
|
@@ -17,18 +17,29 @@ import { Span } from "../models/span.model";
|
|
|
17
17
|
import { EventContextManager, injectConfig, moduleScoped, ServiceDefinitionTagEnum, tag, TracingContext } from "@pristine-ts/common";
|
|
18
18
|
import { SpanKeynameEnum } from "../enums/span-keyname.enum";
|
|
19
19
|
import { TelemetryModuleKeyname } from "../telemetry.module.keyname";
|
|
20
|
+
import { SpanEvent } from "../models/span-event.model";
|
|
20
21
|
/**
|
|
21
22
|
* The Tracing Manager provides methods to help with tracing.
|
|
22
23
|
* It is tagged and can be injected using TracingManagerInterface which facilitates mocking.
|
|
23
24
|
* It is module scoped to the TelemetryModuleKeyname.
|
|
24
25
|
*
|
|
26
|
+
* **Where the active `Trace` lives.** The active trace is stored on `EventContext.trace`,
|
|
27
|
+
* propagated via `AsyncLocalStorage`. Every `TracingManager` instance — whether resolved
|
|
28
|
+
* from the root container (kernel boot) or from a per-event child container — reads and
|
|
29
|
+
* writes spans through the same `EventContext.trace` reference, so a span started in the
|
|
30
|
+
* kernel and an event added in a controller belong to the same trace tree.
|
|
31
|
+
*
|
|
32
|
+
* **Fallback `this.trace`.** During kernel boot (`Kernel.start()` and friends), there is
|
|
33
|
+
* no `EventContext` yet — the framework hasn't started handling an event. In that window
|
|
34
|
+
* the manager falls back to `this.trace`. This is the only time `this.trace` is touched.
|
|
35
|
+
*
|
|
25
36
|
* **Lifecycle: container-scoped, not singleton.** Each per-event DI child container gets
|
|
26
|
-
* its own `TracingManager` instance
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
37
|
+
* its own `TracingManager` instance. The per-instance `this.trace` fallback is what keeps
|
|
38
|
+
* parallel events isolated *if* tracing is somehow started outside an EventContext.
|
|
39
|
+
* Resolving `TracingManager` from the root container returns the root instance (used for
|
|
40
|
+
* kernel-initialization spans); resolving from a child container returns the per-event
|
|
41
|
+
* instance — both will agree on what trace is active inside an event because they read
|
|
42
|
+
* from EventContext.
|
|
32
43
|
*/
|
|
33
44
|
let TracingManager = class TracingManager {
|
|
34
45
|
/**
|
|
@@ -48,10 +59,27 @@ let TracingManager = class TracingManager {
|
|
|
48
59
|
this.isActive = isActive;
|
|
49
60
|
this.debug = debug;
|
|
50
61
|
this.tracingContext = tracingContext;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns the currently active trace from the EventContext, falling back to the
|
|
65
|
+
* per-instance `this.trace` when no EventContext is active (kernel boot).
|
|
66
|
+
*/
|
|
67
|
+
getActiveTrace() {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
return (_b = (_a = EventContextManager.current()) === null || _a === void 0 ? void 0 : _a.trace) !== null && _b !== void 0 ? _b : this.trace;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Stores `trace` as the active trace — on `EventContext.trace` when an event is active,
|
|
73
|
+
* otherwise on the instance fallback `this.trace`.
|
|
74
|
+
*/
|
|
75
|
+
setActiveTrace(trace) {
|
|
76
|
+
const eventContext = EventContextManager.current();
|
|
77
|
+
if (eventContext !== undefined) {
|
|
78
|
+
eventContext.trace = trace;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
this.trace = trace;
|
|
82
|
+
}
|
|
55
83
|
}
|
|
56
84
|
/**
|
|
57
85
|
* This methods starts the Tracing. This should be the first method called before doing anything else.
|
|
@@ -60,17 +88,18 @@ let TracingManager = class TracingManager {
|
|
|
60
88
|
* @param context The context if there is one.
|
|
61
89
|
*/
|
|
62
90
|
startTracing(spanRootKeyname = SpanKeynameEnum.RootExecution, traceId, context) {
|
|
63
|
-
|
|
91
|
+
const trace = new Trace(traceId, context);
|
|
92
|
+
this.setActiveTrace(trace);
|
|
64
93
|
const span = new Span(spanRootKeyname, undefined, context);
|
|
65
94
|
// Mirror the trace id into both the legacy `TracingContext` (back-compat for any
|
|
66
95
|
// existing consumer that still injects it) and the new ALS-propagated `EventContext`
|
|
67
96
|
// (the path forward; what `LogHandler` and other ALS-aware consumers will read).
|
|
68
97
|
// Both writes are cheap; the dual write is just a transition aid until TracingContext
|
|
69
98
|
// is fully removed in a later major.
|
|
70
|
-
this.tracingContext.traceId =
|
|
99
|
+
this.tracingContext.traceId = trace.id;
|
|
71
100
|
const eventContext = EventContextManager.current();
|
|
72
101
|
if (eventContext !== undefined) {
|
|
73
|
-
eventContext.traceId =
|
|
102
|
+
eventContext.traceId = trace.id;
|
|
74
103
|
}
|
|
75
104
|
// If the tracing is not active, simply return the created span but don't send to the tracers.
|
|
76
105
|
if (this.isActive === false) {
|
|
@@ -82,17 +111,17 @@ let TracingManager = class TracingManager {
|
|
|
82
111
|
spanRootKeyname,
|
|
83
112
|
traceId,
|
|
84
113
|
context,
|
|
85
|
-
trace
|
|
114
|
+
trace,
|
|
86
115
|
span,
|
|
87
116
|
});
|
|
88
117
|
}
|
|
89
118
|
// Call the tracers and push the trace that was just started
|
|
90
119
|
this.tracers.forEach((tracer) => {
|
|
91
120
|
var _a;
|
|
92
|
-
(_a = tracer.traceStartedStream) === null || _a === void 0 ? void 0 : _a.push(
|
|
121
|
+
(_a = tracer.traceStartedStream) === null || _a === void 0 ? void 0 : _a.push(trace);
|
|
93
122
|
});
|
|
94
123
|
// Define the rootSpan of the trace as the newly created Span. This is the root span.
|
|
95
|
-
|
|
124
|
+
trace.rootSpan = span;
|
|
96
125
|
// Call the addSpan method to ensure that the span will be added.
|
|
97
126
|
this.addSpan(span);
|
|
98
127
|
return span;
|
|
@@ -108,29 +137,31 @@ let TracingManager = class TracingManager {
|
|
|
108
137
|
var _a;
|
|
109
138
|
// Make sure a trace exists. `startTracing` is the canonical entry point, but a direct
|
|
110
139
|
// `startSpan` call (e.g. from project code) should auto-start a trace rather than fail.
|
|
111
|
-
|
|
140
|
+
let trace = this.getActiveTrace();
|
|
141
|
+
if (trace === undefined) {
|
|
112
142
|
this.startTracing(SpanKeynameEnum.RootExecution, undefined, context);
|
|
143
|
+
trace = this.getActiveTrace();
|
|
113
144
|
}
|
|
114
145
|
// Construct the span. NOTE the third constructor argument: `Span(keyname, id?, context?)`.
|
|
115
146
|
// A previous version of this code passed `context` in the `id` slot, which corrupted span
|
|
116
|
-
// identities and broke parent-by-id lookup
|
|
147
|
+
// identities and broke parent-by-id lookup silently. Always pass `undefined`
|
|
117
148
|
// for the id so a fresh UUID is generated, and put context in the third slot.
|
|
118
149
|
const span = new Span(keyname, undefined, context);
|
|
119
150
|
// Defensive: tracing must never throw. If the trace is somehow still undefined here
|
|
120
151
|
// (an exception inside `startTracing` that we swallowed and logged), return the bare
|
|
121
152
|
// span so the caller can still call `.end()` on it without exploding.
|
|
122
|
-
if (
|
|
153
|
+
if (trace === undefined) {
|
|
123
154
|
this.loghandler.error("Trace is undefined after startTracing; returning unattached span.", { span });
|
|
124
155
|
return span;
|
|
125
156
|
}
|
|
126
|
-
span.trace =
|
|
157
|
+
span.trace = trace;
|
|
127
158
|
// Resolve the parent span. The default parent is the trace's rootSpan, but we may not
|
|
128
159
|
// have one if the trace was started via a path that didn't set it (programming error
|
|
129
160
|
// upstream, but we tolerate it). When no rootSpan exists, attach the new span as a
|
|
130
161
|
// top-level orphan and warn-log once instead of crashing.
|
|
131
|
-
let parentSpan =
|
|
162
|
+
let parentSpan = trace.rootSpan;
|
|
132
163
|
if (parentKeyname) {
|
|
133
|
-
const parentSpans =
|
|
164
|
+
const parentSpans = trace.spansByKeyname[parentKeyname];
|
|
134
165
|
if (parentSpans) {
|
|
135
166
|
if (parentSpans.length > 1) {
|
|
136
167
|
if (parentId) {
|
|
@@ -149,7 +180,7 @@ let TracingManager = class TracingManager {
|
|
|
149
180
|
this.loghandler.warning("startSpan: no parent span available (rootSpan is undefined). Attaching as orphan.", {
|
|
150
181
|
keyname,
|
|
151
182
|
parentKeyname,
|
|
152
|
-
traceId:
|
|
183
|
+
traceId: trace.id,
|
|
153
184
|
});
|
|
154
185
|
}
|
|
155
186
|
else {
|
|
@@ -166,18 +197,20 @@ let TracingManager = class TracingManager {
|
|
|
166
197
|
// Tracing must never throw. If there's no active trace, log and return the span
|
|
167
198
|
// unchanged — caller can still call `.end()` on it because Span.end uses optional
|
|
168
199
|
// chaining on tracingManager.
|
|
169
|
-
|
|
200
|
+
const trace = this.getActiveTrace();
|
|
201
|
+
if (trace === undefined) {
|
|
170
202
|
this.loghandler.error("You cannot call 'addSpan' without having an existing Trace.", { span });
|
|
171
203
|
return span;
|
|
172
204
|
}
|
|
173
205
|
span.tracingManager = this;
|
|
174
|
-
span.trace =
|
|
175
|
-
// Add it to the
|
|
176
|
-
|
|
177
|
-
|
|
206
|
+
span.trace = trace;
|
|
207
|
+
// Add it to the trace's by-keyname index so any TracingManager instance sharing this
|
|
208
|
+
// trace (via EventContext) can find it.
|
|
209
|
+
if (!trace.spansByKeyname[span.keyname]) {
|
|
210
|
+
trace.spansByKeyname[span.keyname] = [span];
|
|
178
211
|
}
|
|
179
212
|
else {
|
|
180
|
-
|
|
213
|
+
trace.spansByKeyname[span.keyname].push(span);
|
|
181
214
|
}
|
|
182
215
|
// If the tracing is deactivated, simply return the span and don't complain.
|
|
183
216
|
if (this.isActive === false) {
|
|
@@ -186,7 +219,7 @@ let TracingManager = class TracingManager {
|
|
|
186
219
|
if (this.debug) {
|
|
187
220
|
this.loghandler.debug(`[span:start] - ${span.keyname}`, {
|
|
188
221
|
keyname: span.keyname,
|
|
189
|
-
trace
|
|
222
|
+
trace,
|
|
190
223
|
span,
|
|
191
224
|
});
|
|
192
225
|
}
|
|
@@ -204,11 +237,16 @@ let TracingManager = class TracingManager {
|
|
|
204
237
|
* @param keyname The keyname of the span to end.
|
|
205
238
|
*/
|
|
206
239
|
endSpanKeyname(keyname) {
|
|
207
|
-
|
|
240
|
+
const trace = this.getActiveTrace();
|
|
241
|
+
if (trace === undefined) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const spans = trace.spansByKeyname[keyname];
|
|
245
|
+
if (!spans) {
|
|
208
246
|
return;
|
|
209
247
|
}
|
|
210
|
-
if (
|
|
211
|
-
return this.endSpan(
|
|
248
|
+
if (spans.length === 1) {
|
|
249
|
+
return this.endSpan(spans[0]);
|
|
212
250
|
}
|
|
213
251
|
this.loghandler.error("Error ending span by keyname since multiple spans exist with this keyname");
|
|
214
252
|
}
|
|
@@ -218,7 +256,7 @@ let TracingManager = class TracingManager {
|
|
|
218
256
|
* @param span The span to end.
|
|
219
257
|
*/
|
|
220
258
|
endSpan(span) {
|
|
221
|
-
var _a
|
|
259
|
+
var _a;
|
|
222
260
|
if (span.inProgress === false) {
|
|
223
261
|
return;
|
|
224
262
|
}
|
|
@@ -233,7 +271,7 @@ let TracingManager = class TracingManager {
|
|
|
233
271
|
}
|
|
234
272
|
if (this.debug) {
|
|
235
273
|
this.loghandler.debug(`[span:end] - ${span.keyname}`, {
|
|
236
|
-
trace: this.
|
|
274
|
+
trace: this.getActiveTrace(),
|
|
237
275
|
span,
|
|
238
276
|
});
|
|
239
277
|
}
|
|
@@ -243,7 +281,8 @@ let TracingManager = class TracingManager {
|
|
|
243
281
|
(_a = tracer.spanEndedStream) === null || _a === void 0 ? void 0 : _a.push(span);
|
|
244
282
|
});
|
|
245
283
|
// If the span is the root span, the trace has ended
|
|
246
|
-
|
|
284
|
+
const trace = this.getActiveTrace();
|
|
285
|
+
if (span.keyname === ((_a = trace === null || trace === void 0 ? void 0 : trace.rootSpan) === null || _a === void 0 ? void 0 : _a.keyname)) {
|
|
247
286
|
this.endTrace();
|
|
248
287
|
}
|
|
249
288
|
}
|
|
@@ -251,16 +290,17 @@ let TracingManager = class TracingManager {
|
|
|
251
290
|
* This method ends the trace entirely.
|
|
252
291
|
*/
|
|
253
292
|
endTrace() {
|
|
254
|
-
|
|
293
|
+
const trace = this.getActiveTrace();
|
|
294
|
+
if (trace === undefined || trace.hasEnded) {
|
|
255
295
|
return;
|
|
256
296
|
}
|
|
257
297
|
// End the trace by setting the end date.
|
|
258
|
-
|
|
298
|
+
trace.endDate = Date.now();
|
|
259
299
|
// End the trace.
|
|
260
|
-
|
|
300
|
+
trace.hasEnded = true;
|
|
261
301
|
// This method will recursively end all the spans
|
|
262
|
-
if (
|
|
263
|
-
this.endSpan(
|
|
302
|
+
if (trace.rootSpan !== undefined) {
|
|
303
|
+
this.endSpan(trace.rootSpan);
|
|
264
304
|
}
|
|
265
305
|
if (this.isActive === false) {
|
|
266
306
|
return;
|
|
@@ -271,9 +311,98 @@ let TracingManager = class TracingManager {
|
|
|
271
311
|
// tree-formatted output when the user opts into it.
|
|
272
312
|
this.tracers.forEach((tracer) => {
|
|
273
313
|
var _a;
|
|
274
|
-
(_a = tracer.traceEndedStream) === null || _a === void 0 ? void 0 : _a.push(
|
|
314
|
+
(_a = tracer.traceEndedStream) === null || _a === void 0 ? void 0 : _a.push(trace);
|
|
275
315
|
});
|
|
276
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* Attaches a named, timestamped event to the most-recently-started in-progress span.
|
|
319
|
+
* Use for noteworthy moments that don't warrant a child span — "validation passed",
|
|
320
|
+
* "found 50 rows", "rate limit ok". Cheap (just pushes onto an array); shows up in
|
|
321
|
+
* the trace rendered by tracers (ConsoleTracer, FileTracer, X-Ray, etc.).
|
|
322
|
+
*
|
|
323
|
+
* If no span is currently active (no trace started, or every span has already ended),
|
|
324
|
+
* a warning is logged and the marker is dropped. The warning is the explicit signal
|
|
325
|
+
* that "this marker call had nowhere to go" — usually the sign of a missing
|
|
326
|
+
* `startTracing()` call earlier in the flow.
|
|
327
|
+
*/
|
|
328
|
+
addEventToCurrentSpan(message, attributes) {
|
|
329
|
+
const target = this.findActiveLeafSpan();
|
|
330
|
+
if (target === undefined) {
|
|
331
|
+
this.loghandler.warning("TracingManager.addEventToCurrentSpan called outside any active trace; marker dropped.", { extra: { message, attributes } });
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
target.events.push(new SpanEvent(message, attributes));
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Returns the active trace's spans + their events as a flat, timestamp-sorted list of
|
|
338
|
+
* `{kind, name, date, attributes}` entries. Public utility for custom tracers, debug
|
|
339
|
+
* endpoints, test helpers, or anyone who wants "the active trace as a flat list."
|
|
340
|
+
* Returns an empty array when no active trace exists.
|
|
341
|
+
*/
|
|
342
|
+
getCurrentTrail() {
|
|
343
|
+
const trace = this.getActiveTrace();
|
|
344
|
+
if ((trace === null || trace === void 0 ? void 0 : trace.rootSpan) === undefined)
|
|
345
|
+
return [];
|
|
346
|
+
const out = [];
|
|
347
|
+
const walk = (span) => {
|
|
348
|
+
var _a, _b;
|
|
349
|
+
const suffix = span.inProgress ? " (active)" : "";
|
|
350
|
+
out.push({
|
|
351
|
+
kind: "span",
|
|
352
|
+
name: `${span.keyname}${suffix}`,
|
|
353
|
+
date: new Date(span.startDate),
|
|
354
|
+
attributes: Object.assign({ spanId: span.id }, ((_a = span.context) !== null && _a !== void 0 ? _a : {})),
|
|
355
|
+
});
|
|
356
|
+
for (const event of span.events) {
|
|
357
|
+
out.push({
|
|
358
|
+
kind: "event",
|
|
359
|
+
name: event.message,
|
|
360
|
+
date: new Date(event.timestamp),
|
|
361
|
+
attributes: Object.assign({ spanKeyname: span.keyname }, ((_b = event.attributes) !== null && _b !== void 0 ? _b : {})),
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
for (const child of span.children) {
|
|
365
|
+
walk(child);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
walk(trace.rootSpan);
|
|
369
|
+
out.sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
370
|
+
return out;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Finds the deepest in-progress span — the leaf of the still-open subtree. Used as
|
|
374
|
+
* the target for `addEventToCurrentSpan`. Intuition: events attach to whatever is
|
|
375
|
+
* currently open at the bottom of the call stack.
|
|
376
|
+
*
|
|
377
|
+
* Walking the in-progress subtree (rather than ranking all spans by start date)
|
|
378
|
+
* avoids the edge case where a parent and child have the same `Date.now()` value —
|
|
379
|
+
* picking the "latest started" by raw timestamp would incorrectly attach to the
|
|
380
|
+
* parent. Depth-first traversal of in-progress children naturally lands on the
|
|
381
|
+
* deepest leaf. Tie-broken by latest start date when multiple leaves exist.
|
|
382
|
+
*
|
|
383
|
+
* Returns undefined when nothing is in progress (no trace, or every span has ended).
|
|
384
|
+
* @private
|
|
385
|
+
*/
|
|
386
|
+
findActiveLeafSpan() {
|
|
387
|
+
const trace = this.getActiveTrace();
|
|
388
|
+
if ((trace === null || trace === void 0 ? void 0 : trace.rootSpan) === undefined)
|
|
389
|
+
return undefined;
|
|
390
|
+
let best;
|
|
391
|
+
const walk = (span) => {
|
|
392
|
+
const inProgressChildren = span.children.filter(c => c.inProgress);
|
|
393
|
+
if (span.inProgress && inProgressChildren.length === 0) {
|
|
394
|
+
// This span is a leaf of the in-progress subtree. Among multiple such leaves,
|
|
395
|
+
// prefer the latest-started one (most recent in time).
|
|
396
|
+
if (best === undefined || span.startDate >= best.startDate) {
|
|
397
|
+
best = span;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
for (const child of inProgressChildren)
|
|
401
|
+
walk(child);
|
|
402
|
+
};
|
|
403
|
+
walk(trace.rootSpan);
|
|
404
|
+
return best;
|
|
405
|
+
}
|
|
277
406
|
};
|
|
278
407
|
TracingManager = __decorate([
|
|
279
408
|
moduleScoped(TelemetryModuleKeyname),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracing.manager.js","sourceRoot":"","sources":["../../../../src/managers/tracing.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAC,0BAA0B,EAAC,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAC,KAAK,EAAC,MAAM,uBAAuB,CAAC;AA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AAyB,CAAC;IAC9B,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;IACjC,UAAU,EAAE;IAmBS,WAAA,SAAS,CAAC,wBAAwB,CAAC,MAAM,EAAE,EAAC,UAAU,EAAE,IAAI,EAAC,CAAC,CAAA;IAC9D,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,YAAY,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAA;IAC/C,WAAA,YAAY,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAA;sEACd,cAAc;GAtBvD,cAAc,CAka1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/models/models.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/models/models.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"span-event.model.js","sourceRoot":"","sources":["../../../../src/models/span-event.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,68 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* This model represents a span.
|
|
4
|
-
*/
|
|
5
|
-
export class Span {
|
|
6
|
-
/**
|
|
7
|
-
* This model represents a span.
|
|
8
|
-
* @param keyname The keyname of the span.
|
|
9
|
-
* @param id The unique id of the span.
|
|
10
|
-
* @param context The context to associate with the span.
|
|
11
|
-
*/
|
|
12
|
-
constructor(keyname, id, context) {
|
|
13
|
-
this.keyname = keyname;
|
|
14
|
-
/**
|
|
15
|
-
* The timestamp in milliseconds at which the span was started.
|
|
16
|
-
*/
|
|
17
|
-
this.startDate = Date.now();
|
|
18
|
-
/**
|
|
19
|
-
* The children spans.
|
|
20
|
-
*/
|
|
21
|
-
this.children = [];
|
|
22
|
-
/**
|
|
23
|
-
* The context associated with the span.
|
|
24
|
-
*/
|
|
25
|
-
this.context = {};
|
|
26
|
-
/**
|
|
27
|
-
* Whether or not the span is in progress, meaning it has not ended.
|
|
28
|
-
*/
|
|
29
|
-
this.inProgress = true;
|
|
30
|
-
this.id = id !== null && id !== void 0 ? id : uuidv4();
|
|
31
|
-
this.context = context !== null && context !== void 0 ? context : {};
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* This method returns the duration of the span in milliseconds.
|
|
35
|
-
*/
|
|
36
|
-
getDuration() {
|
|
37
|
-
var _a;
|
|
38
|
-
return ((_a = this.endDate) !== null && _a !== void 0 ? _a : Date.now()) - this.startDate;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* This method ends the span.
|
|
42
|
-
*/
|
|
43
|
-
end() {
|
|
44
|
-
var _a;
|
|
45
|
-
(_a = this.tracingManager) === null || _a === void 0 ? void 0 : _a.endSpan(this);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* This method sets the trace for the span and all of its children.
|
|
49
|
-
* @param trace The trace the span should be attached to.
|
|
50
|
-
*/
|
|
51
|
-
setTrace(trace) {
|
|
52
|
-
this.trace = trace;
|
|
53
|
-
this.children.forEach(childSpan => childSpan.setTrace(trace));
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* This method adds a child span to the current span. It only adds it if it's not already part of the children.
|
|
57
|
-
* @param span The span to add as a child.
|
|
58
|
-
*/
|
|
59
|
-
addChild(span) {
|
|
60
|
-
const existingChildSpan = this.children.find(childSpan => childSpan.id === span.id);
|
|
61
|
-
if (existingChildSpan) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
span.parentSpan = this;
|
|
65
|
-
this.children.push(span);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
1
|
+
export { Span } from "@pristine-ts/common";
|
|
68
2
|
//# sourceMappingURL=span.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"span.model.js","sourceRoot":"","sources":["../../../../src/models/span.model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"span.model.js","sourceRoot":"","sources":["../../../../src/models/span.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAA8B,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* This model represents a trace.
|
|
4
|
-
*/
|
|
5
|
-
export class Trace {
|
|
6
|
-
/**
|
|
7
|
-
* This model represents a trace.
|
|
8
|
-
* @param id The unique id of the trace.
|
|
9
|
-
* @param context The context associated with the trace.
|
|
10
|
-
*/
|
|
11
|
-
constructor(id, context) {
|
|
12
|
-
/**
|
|
13
|
-
* The timestamp in milliseconds at which the trace was started.
|
|
14
|
-
*/
|
|
15
|
-
this.startDate = Date.now();
|
|
16
|
-
/**
|
|
17
|
-
* The context associated with the trace.
|
|
18
|
-
*/
|
|
19
|
-
this.context = {};
|
|
20
|
-
/**
|
|
21
|
-
* Whether or not the trace was ended.
|
|
22
|
-
*/
|
|
23
|
-
this.hasEnded = false;
|
|
24
|
-
this.id = id !== null && id !== void 0 ? id : uuidv4();
|
|
25
|
-
this.context = context !== null && context !== void 0 ? context : {};
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* This returns the duration of the trace in miliseconds.
|
|
29
|
-
*/
|
|
30
|
-
getDuration() {
|
|
31
|
-
var _a;
|
|
32
|
-
return ((_a = this.endDate) !== null && _a !== void 0 ? _a : Date.now()) - this.startDate;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
export { Trace } from "@pristine-ts/common";
|
|
35
2
|
//# sourceMappingURL=trace.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.model.js","sourceRoot":"","sources":["../../../../src/models/trace.model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"trace.model.js","sourceRoot":"","sources":["../../../../src/models/trace.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC"}
|
|
@@ -3,7 +3,6 @@ import { TelemetryModuleKeyname } from "./telemetry.module.keyname";
|
|
|
3
3
|
import { LoggingModule } from "@pristine-ts/logging";
|
|
4
4
|
import { BooleanResolver, EnumResolver, EnvironmentVariableResolver, NumberResolver } from "@pristine-ts/configuration";
|
|
5
5
|
import { ConsoleTracerOutputModeEnum } from "./enums/console-tracer-output-mode.enum";
|
|
6
|
-
export * from "./decorators/decorators";
|
|
7
6
|
export * from "./enums/enums";
|
|
8
7
|
export * from "./interfaces/interfaces";
|
|
9
8
|
export * from "./managers/managers";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.module.js","sourceRoot":"","sources":["../../../src/telemetry.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAC,sBAAsB,EAAC,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAC,eAAe,EAAE,YAAY,EAAE,2BAA2B,EAAE,cAAc,EAAC,MAAM,4BAA4B,CAAC;AACtH,OAAO,EAAC,2BAA2B,EAAC,MAAM,yCAAyC,CAAC;AAEpF,cAAc,
|
|
1
|
+
{"version":3,"file":"telemetry.module.js","sourceRoot":"","sources":["../../../src/telemetry.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAC,sBAAsB,EAAC,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAC,eAAe,EAAE,YAAY,EAAE,2BAA2B,EAAE,cAAc,EAAC,MAAM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