@senpi/runtime 1.1.0-dev.runtime-phase-2.20260609132603 → 1.1.0-dev.runtime-phase-2.20260610130051
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/actions/close-position/close-position.action.d.ts +0 -16
- package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
- package/dist/actions/close-position/close-position.action.js +38 -299
- package/dist/actions/close-position/close-position.action.js.map +1 -1
- package/dist/actions/decision-engine.d.ts +0 -2
- package/dist/actions/decision-engine.d.ts.map +1 -1
- package/dist/actions/decision-engine.js.map +1 -1
- package/dist/actions/llm-decision/factory.d.ts +0 -3
- package/dist/actions/llm-decision/factory.d.ts.map +1 -1
- package/dist/actions/llm-decision/factory.js +0 -1
- package/dist/actions/llm-decision/factory.js.map +1 -1
- package/dist/actions/llm-decision/openclaw-llm-decision.d.ts +0 -13
- package/dist/actions/llm-decision/openclaw-llm-decision.d.ts.map +1 -1
- package/dist/actions/llm-decision/openclaw-llm-decision.js +68 -195
- package/dist/actions/llm-decision/openclaw-llm-decision.js.map +1 -1
- package/dist/actions/open-position/open-position.action.d.ts +0 -12
- package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
- package/dist/actions/open-position/open-position.action.js +123 -346
- package/dist/actions/open-position/open-position.action.js.map +1 -1
- package/dist/actions/position-tracker/position-tracker.action.d.ts +0 -6
- package/dist/actions/position-tracker/position-tracker.action.d.ts.map +1 -1
- package/dist/actions/position-tracker/position-tracker.action.js +0 -48
- package/dist/actions/position-tracker/position-tracker.action.js.map +1 -1
- package/dist/dsl/events/handlers.d.ts.map +1 -1
- package/dist/dsl/events/handlers.js +4 -0
- package/dist/dsl/events/handlers.js.map +1 -1
- package/dist/recording/emitter.d.ts +21 -0
- package/dist/recording/emitter.d.ts.map +1 -0
- package/dist/recording/emitter.js +2 -0
- package/dist/recording/emitter.js.map +1 -0
- package/dist/recording/identity.d.ts +34 -0
- package/dist/recording/identity.d.ts.map +1 -0
- package/dist/recording/identity.js +2 -0
- package/dist/recording/identity.js.map +1 -0
- package/dist/recording/index.d.ts +11 -0
- package/dist/recording/index.d.ts.map +1 -0
- package/dist/recording/index.js +2 -0
- package/dist/recording/index.js.map +1 -0
- package/dist/recording/noop-emitter.d.ts +17 -0
- package/dist/recording/noop-emitter.d.ts.map +1 -0
- package/dist/recording/noop-emitter.js +16 -0
- package/dist/recording/noop-emitter.js.map +1 -0
- package/dist/recording/otel/attributes.d.ts +35 -0
- package/dist/recording/otel/attributes.d.ts.map +1 -0
- package/dist/recording/otel/attributes.js +131 -0
- package/dist/recording/otel/attributes.js.map +1 -0
- package/dist/recording/otel/constants.d.ts +81 -0
- package/dist/recording/otel/constants.d.ts.map +1 -0
- package/dist/recording/otel/constants.js +96 -0
- package/dist/recording/otel/constants.js.map +1 -0
- package/dist/recording/otel/ids.d.ts +14 -0
- package/dist/recording/otel/ids.d.ts.map +1 -0
- package/dist/recording/otel/ids.js +12 -0
- package/dist/recording/otel/ids.js.map +1 -0
- package/dist/recording/otel/index.d.ts +13 -0
- package/dist/recording/otel/index.d.ts.map +1 -0
- package/dist/recording/otel/index.js +9 -0
- package/dist/recording/otel/index.js.map +1 -0
- package/dist/recording/otel/mappers.d.ts +42 -0
- package/dist/recording/otel/mappers.d.ts.map +1 -0
- package/dist/recording/otel/mappers.js +337 -0
- package/dist/recording/otel/mappers.js.map +1 -0
- package/dist/recording/otel/otel-emitter.d.ts +37 -0
- package/dist/recording/otel/otel-emitter.d.ts.map +1 -0
- package/dist/recording/otel/otel-emitter.js +75 -0
- package/dist/recording/otel/otel-emitter.js.map +1 -0
- package/dist/recording/otel/redaction.d.ts +31 -0
- package/dist/recording/otel/redaction.d.ts.map +1 -0
- package/dist/recording/otel/redaction.js +40 -0
- package/dist/recording/otel/redaction.js.map +1 -0
- package/dist/recording/records.d.ts +327 -0
- package/dist/recording/records.d.ts.map +1 -0
- package/dist/recording/records.js +14 -0
- package/dist/recording/records.js.map +1 -0
- package/dist/recording/transport/batcher.d.ts +59 -0
- package/dist/recording/transport/batcher.d.ts.map +1 -0
- package/dist/recording/transport/batcher.js +234 -0
- package/dist/recording/transport/batcher.js.map +1 -0
- package/dist/recording/transport/client.d.ts +41 -0
- package/dist/recording/transport/client.d.ts.map +1 -0
- package/dist/recording/transport/client.js +69 -0
- package/dist/recording/transport/client.js.map +1 -0
- package/dist/recording/transport/config.d.ts +53 -0
- package/dist/recording/transport/config.d.ts.map +1 -0
- package/dist/recording/transport/config.js +41 -0
- package/dist/recording/transport/config.js.map +1 -0
- package/dist/recording/transport/index.d.ts +16 -0
- package/dist/recording/transport/index.d.ts.map +1 -0
- package/dist/recording/transport/index.js +12 -0
- package/dist/recording/transport/index.js.map +1 -0
- package/dist/recording/transport/rows.d.ts +88 -0
- package/dist/recording/transport/rows.d.ts.map +1 -0
- package/dist/recording/transport/rows.js +15 -0
- package/dist/recording/transport/rows.js.map +1 -0
- package/dist/recording/wiring/emitter-factory.d.ts +39 -0
- package/dist/recording/wiring/emitter-factory.d.ts.map +1 -0
- package/dist/recording/wiring/emitter-factory.js +62 -0
- package/dist/recording/wiring/emitter-factory.js.map +1 -0
- package/dist/recording/wiring/identity.d.ts +27 -0
- package/dist/recording/wiring/identity.d.ts.map +1 -0
- package/dist/recording/wiring/identity.js +51 -0
- package/dist/recording/wiring/identity.js.map +1 -0
- package/dist/recording/wiring/index.d.ts +12 -0
- package/dist/recording/wiring/index.d.ts.map +1 -0
- package/dist/recording/wiring/index.js +9 -0
- package/dist/recording/wiring/index.js.map +1 -0
- package/dist/recording/wiring/record-builders.d.ts +68 -0
- package/dist/recording/wiring/record-builders.d.ts.map +1 -0
- package/dist/recording/wiring/record-builders.js +441 -0
- package/dist/recording/wiring/record-builders.js.map +1 -0
- package/dist/recording/wiring/subscriber.d.ts +21 -0
- package/dist/recording/wiring/subscriber.d.ts.map +1 -0
- package/dist/recording/wiring/subscriber.js +171 -0
- package/dist/recording/wiring/subscriber.js.map +1 -0
- package/dist/recording/wiring/values.d.ts +19 -0
- package/dist/recording/wiring/values.d.ts.map +1 -0
- package/dist/recording/wiring/values.js +49 -0
- package/dist/recording/wiring/values.js.map +1 -0
- package/dist/runtime/create-actions.d.ts.map +1 -1
- package/dist/runtime/create-actions.js +0 -2
- package/dist/runtime/create-actions.js.map +1 -1
- package/dist/runtime/create-runtime-context.d.ts +0 -2
- package/dist/runtime/create-runtime-context.d.ts.map +1 -1
- package/dist/runtime/create-runtime-context.js +0 -1
- package/dist/runtime/create-runtime-context.js.map +1 -1
- package/dist/runtime/create-scanner-module.d.ts +1 -1
- package/dist/runtime/create-scanner-module.d.ts.map +1 -1
- package/dist/runtime/create-scanner-module.js +1 -2
- package/dist/runtime/create-scanner-module.js.map +1 -1
- package/dist/runtime/load-runtime-config.d.ts +9 -0
- package/dist/runtime/load-runtime-config.d.ts.map +1 -1
- package/dist/runtime/load-runtime-config.js +41 -1
- package/dist/runtime/load-runtime-config.js.map +1 -1
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +3 -2
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/runtime-schema.d.ts +182 -24
- package/dist/runtime/runtime-schema.d.ts.map +1 -1
- package/dist/runtime/runtime-schema.js +17 -1
- package/dist/runtime/runtime-schema.js.map +1 -1
- package/dist/runtime/runtime.d.ts +15 -5
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +248 -273
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/scanners/engine/data-providers.d.ts +0 -2
- package/dist/scanners/engine/data-providers.d.ts.map +1 -1
- package/dist/scanners/engine/data-providers.js.map +1 -1
- package/dist/scanners/engine/engine.d.ts.map +1 -1
- package/dist/scanners/engine/engine.js +9 -68
- package/dist/scanners/engine/engine.js.map +1 -1
- package/dist/scanners/events.d.ts +6 -0
- package/dist/scanners/events.d.ts.map +1 -1
- package/dist/scanners/events.js.map +1 -1
- package/dist/scanners/runtime-module.d.ts +0 -2
- package/dist/scanners/runtime-module.d.ts.map +1 -1
- package/dist/scanners/runtime-module.js +9 -2
- package/dist/scanners/runtime-module.js.map +1 -1
- package/dist/senpi/client.d.ts +2 -2
- package/dist/senpi/client.d.ts.map +1 -1
- package/dist/senpi/client.js +20 -120
- package/dist/senpi/client.js.map +1 -1
- package/dist/senpi/types.d.ts +1 -68
- package/dist/senpi/types.d.ts.map +1 -1
- package/dist/strategy/strategy-state.d.ts +1 -1
- package/dist/strategy/strategy-state.d.ts.map +1 -1
- package/dist/tracking/spans/plugin-span-tracker.d.ts.map +1 -1
- package/dist/tracking/spans/plugin-span-tracker.js +24 -4
- package/dist/tracking/spans/plugin-span-tracker.js.map +1 -1
- package/dist/tracking/spans/redact-pii.d.ts +0 -10
- package/dist/tracking/spans/redact-pii.d.ts.map +1 -1
- package/dist/tracking/spans/redact-pii.js +2 -80
- package/dist/tracking/spans/redact-pii.js.map +1 -1
- package/dist/types/runtime.d.ts +0 -3
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/strategy.d.ts +2 -2
- package/dist/types/strategy.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/actions/otel-helpers.d.ts +0 -65
- package/dist/actions/otel-helpers.d.ts.map +0 -1
- package/dist/actions/otel-helpers.js +0 -122
- package/dist/actions/otel-helpers.js.map +0 -1
- package/dist/otel/context.d.ts +0 -24
- package/dist/otel/context.d.ts.map +0 -1
- package/dist/otel/context.js +0 -29
- package/dist/otel/context.js.map +0 -1
- package/dist/otel/emitter.d.ts +0 -73
- package/dist/otel/emitter.d.ts.map +0 -1
- package/dist/otel/emitter.js +0 -248
- package/dist/otel/emitter.js.map +0 -1
- package/dist/otel/encode.d.ts +0 -48
- package/dist/otel/encode.d.ts.map +0 -1
- package/dist/otel/encode.js +0 -100
- package/dist/otel/encode.js.map +0 -1
- package/dist/otel/index.d.ts +0 -13
- package/dist/otel/index.d.ts.map +0 -1
- package/dist/otel/index.js +0 -10
- package/dist/otel/index.js.map +0 -1
- package/dist/otel/transport.d.ts +0 -57
- package/dist/otel/transport.d.ts.map +0 -1
- package/dist/otel/transport.js +0 -208
- package/dist/otel/transport.js.map +0 -1
- package/dist/otel/types.d.ts +0 -62
- package/dist/otel/types.d.ts.map +0 -1
- package/dist/otel/types.js +0 -2
- package/dist/otel/types.js.map +0 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attribute flattening + the timestamp/duration conversions. The flattening rule is the central
|
|
3
|
+
* query convention: dotted lowercase snake_case keys, `String(v)` values (booleans as
|
|
4
|
+
* `"true"`/`"false"`), null/undefined omitted, open bags flattened one level, arrays as a single
|
|
5
|
+
* JSON-string key. Caps bound a row well under the batcher's body cap.
|
|
6
|
+
*
|
|
7
|
+
* Order within a row is: redact (typed-field, upstream) → flatten (here) → cap (here).
|
|
8
|
+
*/
|
|
9
|
+
import { MAX_ATTR_VALUE_CHARS, MAX_BAG_KEYS, MAX_CONFIG_CHARS, MAX_TOTAL_ATTR_CHARS, TRUNCATE_MARKER, } from "./constants.js";
|
|
10
|
+
/**
|
|
11
|
+
* Non-finite or negative epoch-ms must not reach `BigInt()` — `BigInt(NaN)`/`BigInt(Infinity)`
|
|
12
|
+
* throw, and a negative timestamp is an invalid wire value. Sanitize to `0n` so one bad clock value
|
|
13
|
+
* degrades a single row rather than throwing and dropping the whole record (every numeric *attribute*
|
|
14
|
+
* is already finite-guarded in {@link AttrBuilder.put}; timestamps bypass that path).
|
|
15
|
+
*/
|
|
16
|
+
function toEpochMs(ms) {
|
|
17
|
+
if (!Number.isFinite(ms) || ms < 0)
|
|
18
|
+
return 0n;
|
|
19
|
+
return BigInt(Math.trunc(ms));
|
|
20
|
+
}
|
|
21
|
+
/** ms → epoch-ns digit string. BigInt: ms·1e6 overflows Number's safe-integer range. */
|
|
22
|
+
export function msToNs(ms) {
|
|
23
|
+
return (toEpochMs(ms) * 1000000n).toString();
|
|
24
|
+
}
|
|
25
|
+
/** Duration ns digit string from a clean `endedAt − startedAt` (clamped ≥ 0 defensively). */
|
|
26
|
+
export function durationNs(startedAt, endedAt) {
|
|
27
|
+
const ns = (toEpochMs(endedAt) - toEpochMs(startedAt)) * 1000000n;
|
|
28
|
+
return (ns < 0n ? 0n : ns).toString();
|
|
29
|
+
}
|
|
30
|
+
/** Truncate a value past the per-value cap, marking it so the cut is visible downstream. */
|
|
31
|
+
function capValue(value, max) {
|
|
32
|
+
if (value.length <= max)
|
|
33
|
+
return value;
|
|
34
|
+
// `max` could be smaller than the marker (defensive: no current caller passes one that small);
|
|
35
|
+
// clamp the kept length to ≥ 0 so the slice index never goes negative.
|
|
36
|
+
return value.slice(0, Math.max(0, max - TRUNCATE_MARKER.length)) + TRUNCATE_MARKER;
|
|
37
|
+
}
|
|
38
|
+
function scalarToString(value) {
|
|
39
|
+
if (typeof value === "boolean")
|
|
40
|
+
return value ? "true" : "false";
|
|
41
|
+
return String(value);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Accumulates a row's flat attribute map, applying the casing/null/cap rules uniformly. Callers add
|
|
45
|
+
* scalars under explicit keys (never auto camel→snake — acronyms mangle), bags one level deep, and
|
|
46
|
+
* arrays/blobs as single JSON keys.
|
|
47
|
+
*/
|
|
48
|
+
export class AttrBuilder {
|
|
49
|
+
attrs = {};
|
|
50
|
+
totalChars = 0;
|
|
51
|
+
/** Set a scalar under an explicit key. null/undefined → omit; over budget → drop silently. */
|
|
52
|
+
put(key, value) {
|
|
53
|
+
if (value === null || value === undefined)
|
|
54
|
+
return this;
|
|
55
|
+
if (typeof value === "number" && !Number.isFinite(value))
|
|
56
|
+
return this;
|
|
57
|
+
this.assign(key, capValue(scalarToString(value), MAX_ATTR_VALUE_CHARS));
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
/** Flatten an open bag ONE level under `prefix` (`prefix.{k}`); scalars `String()`, else JSON. */
|
|
61
|
+
putBag(prefix, bag) {
|
|
62
|
+
if (!bag)
|
|
63
|
+
return this;
|
|
64
|
+
let count = 0;
|
|
65
|
+
for (const [k, v] of Object.entries(bag)) {
|
|
66
|
+
if (count >= MAX_BAG_KEYS)
|
|
67
|
+
break;
|
|
68
|
+
if (v === null || v === undefined)
|
|
69
|
+
continue;
|
|
70
|
+
const str = typeof v === "object" ? safeJson(v) : scalarToString(v);
|
|
71
|
+
if (str === undefined)
|
|
72
|
+
continue;
|
|
73
|
+
// Count only keys actually emitted, so MAX_BAG_KEYS means "emitted" not "attempted" even
|
|
74
|
+
// when the total-attr guard drops some.
|
|
75
|
+
if (this.assign(`${prefix}.${k}`, capValue(str, MAX_ATTR_VALUE_CHARS)))
|
|
76
|
+
count++;
|
|
77
|
+
}
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
/** `Record<string,boolean>` → `prefix.{name} = "true"|"false"`. */
|
|
81
|
+
putFactors(prefix, factors) {
|
|
82
|
+
if (!factors)
|
|
83
|
+
return this;
|
|
84
|
+
let count = 0;
|
|
85
|
+
for (const [name, v] of Object.entries(factors)) {
|
|
86
|
+
if (count >= MAX_BAG_KEYS)
|
|
87
|
+
break;
|
|
88
|
+
if (this.assign(`${prefix}.${name}`, v ? "true" : "false"))
|
|
89
|
+
count++;
|
|
90
|
+
}
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
/** A single JSON-string key for an array or structured value (queried rarely, structure kept). */
|
|
94
|
+
putJson(key, value, maxChars = MAX_ATTR_VALUE_CHARS) {
|
|
95
|
+
if (value === null || value === undefined)
|
|
96
|
+
return this;
|
|
97
|
+
const str = safeJson(value);
|
|
98
|
+
if (str === undefined)
|
|
99
|
+
return this;
|
|
100
|
+
this.assign(key, capValue(str, maxChars));
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
/** The `runtime.config` blob: single JSON key, larger size cap, never flattened. */
|
|
104
|
+
putConfig(key, value) {
|
|
105
|
+
return this.putJson(key, value, MAX_CONFIG_CHARS);
|
|
106
|
+
}
|
|
107
|
+
/** Assign under the total-attr guard. Returns whether the key was actually stored. */
|
|
108
|
+
assign(key, value) {
|
|
109
|
+
// Total-attr guard: once the row's attrs hit the budget, drop further keys rather than let one
|
|
110
|
+
// record blow past the batcher's body cap.
|
|
111
|
+
if (this.totalChars + key.length + value.length > MAX_TOTAL_ATTR_CHARS)
|
|
112
|
+
return false;
|
|
113
|
+
this.attrs[key] = value;
|
|
114
|
+
this.totalChars += key.length + value.length;
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
build() {
|
|
118
|
+
return this.attrs;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** `JSON.stringify` that never throws (circular refs etc.) — returns undefined on failure. */
|
|
122
|
+
function safeJson(value) {
|
|
123
|
+
try {
|
|
124
|
+
const s = JSON.stringify(value);
|
|
125
|
+
return s === undefined ? undefined : s;
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../../src/recording/otel/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB;;;;;GAKG;AACH,SAAS,SAAS,CAAC,EAAU;IAC3B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IAC9C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AAChC,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,MAAM,CAAC,EAAU;IAC/B,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,QAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;AACjD,CAAC;AAED,6FAA6F;AAC7F,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AAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query-load-bearing constants for the mapper: span/event names, the severity map, scope
|
|
3
|
+
* identity, attribute namespaces, and the size caps. These are part of the telemetry contract —
|
|
4
|
+
* changing a name or a severity breaks saved queries downstream, so they live in one pinned place.
|
|
5
|
+
*/
|
|
6
|
+
import type { SpanKind } from "../transport/index.js";
|
|
7
|
+
import type { RecordingRecord } from "../records.js";
|
|
8
|
+
/** One constant pair for this emitter. `ScopeVersion` is injectable on the emitter for the
|
|
9
|
+
* real package version (Task 4 wiring); this is the default. */
|
|
10
|
+
export declare const SCOPE_NAME = "senpi.recording";
|
|
11
|
+
export declare const SCOPE_VERSION = "1.1.1";
|
|
12
|
+
export declare const SPAN_NAME: {
|
|
13
|
+
readonly scannerRun: "scanner.run";
|
|
14
|
+
/** Root span of a signal-evaluation pass. */
|
|
15
|
+
readonly signalPass: "signal.evaluation_pass";
|
|
16
|
+
/** One child span per evaluated signal within a pass. */
|
|
17
|
+
readonly signalEvaluation: "signal.evaluation";
|
|
18
|
+
};
|
|
19
|
+
/** OTEL-idiomatic span event recording an error on a span. */
|
|
20
|
+
export declare const EXCEPTION_EVENT_NAME = "exception";
|
|
21
|
+
/** OTEL SeverityNumber/SeverityText pairs. */
|
|
22
|
+
export interface Severity {
|
|
23
|
+
readonly number: number;
|
|
24
|
+
readonly text: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const SEVERITY: {
|
|
27
|
+
readonly INFO: {
|
|
28
|
+
readonly number: 9;
|
|
29
|
+
readonly text: "INFO";
|
|
30
|
+
};
|
|
31
|
+
readonly WARN: {
|
|
32
|
+
readonly number: 13;
|
|
33
|
+
readonly text: "WARN";
|
|
34
|
+
};
|
|
35
|
+
readonly ERROR: {
|
|
36
|
+
readonly number: 17;
|
|
37
|
+
readonly text: "ERROR";
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Per-record/outcome severity map (deliberately not constant). Errors → ERROR; a self-pause is a
|
|
42
|
+
* WARN-worthy operational event; every other discrete event is INFO.
|
|
43
|
+
*/
|
|
44
|
+
export declare function severityFor(record: RecordingRecord): Severity;
|
|
45
|
+
/**
|
|
46
|
+
* `EventName` scheme: `{type}` for records with no sub-enum, `{type}.{discriminator}` where a
|
|
47
|
+
* discriminating enum exists — so `position_lifecycle.opened`, `dsl_transition.sl_updated`,
|
|
48
|
+
* `runtime_state.paused` are all directly filterable.
|
|
49
|
+
*/
|
|
50
|
+
export declare function eventNameFor(record: RecordingRecord): string;
|
|
51
|
+
export type RecordRoute = {
|
|
52
|
+
readonly kind: "trace";
|
|
53
|
+
readonly spanKind: SpanKind;
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: "log";
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Declarative trace-vs-log routing for all 7 record types. Heuristic: durationful *work units* are
|
|
59
|
+
* spans; discrete events and errors are logs. The two point-in-time domain events
|
|
60
|
+
* (`position_lifecycle`, `runtime_lifecycle`) are logs, not zero-duration spans — they carry no
|
|
61
|
+
* duration, and logs are the natural home for point-in-time events, which keeps the trace view
|
|
62
|
+
* exclusively work units. (Severity for log routes comes from {@link severityFor}.)
|
|
63
|
+
*/
|
|
64
|
+
export declare const ROUTING: {
|
|
65
|
+
readonly [K in RecordingRecord["type"]]: RecordRoute;
|
|
66
|
+
};
|
|
67
|
+
/** `1` = sampled. `0` reads as "dropped" to OTEL consumers, so always emit `1`. */
|
|
68
|
+
export declare const TRACE_FLAGS_SAMPLED = 1;
|
|
69
|
+
/** Replacement for a scrubbed scalar value; presence is kept, content removed. */
|
|
70
|
+
export declare const REDACT_MARKER = "[redacted]";
|
|
71
|
+
/** Per-value character cap; longer values are truncated with {@link TRUNCATE_MARKER}. */
|
|
72
|
+
export declare const MAX_ATTR_VALUE_CHARS = 4096;
|
|
73
|
+
/** Marker appended to a truncated value. */
|
|
74
|
+
export declare const TRUNCATE_MARKER = "\u2026[truncated]";
|
|
75
|
+
/** Max keys flattened out of a single open bag, bounding key cardinality from an unbounded bag. */
|
|
76
|
+
export declare const MAX_BAG_KEYS = 64;
|
|
77
|
+
/** Char cap for the single `runtime.config` JSON blob (larger than a normal value, still bounded). */
|
|
78
|
+
export declare const MAX_CONFIG_CHARS = 16384;
|
|
79
|
+
/** Total character budget across one row's attribute map — the total-attr guard. */
|
|
80
|
+
export declare const MAX_TOTAL_ATTR_CHARS = 65536;
|
|
81
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/recording/otel/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD;iEACiE;AACjE,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAC5C,eAAO,MAAM,aAAa,UAAU,CAAC;AAGrC,eAAO,MAAM,SAAS;;IAEpB,6CAA6C;;IAE7C,yDAAyD;;CAEjD,CAAC;AAEX,8DAA8D;AAC9D,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAGhD,8CAA8C;AAC9C,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AACD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;CAIwB,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,GAAG,QAAQ,CAS7D;AAGD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAgB5D;AAGD,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GACvD;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAE7B;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,EAAE;IAAE,QAAQ,EAAE,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,GAAG,WAAW;CAQlE,CAAC;AAGX,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAGrC,kFAAkF;AAClF,eAAO,MAAM,aAAa,eAAe,CAAC;AAG1C,yFAAyF;AACzF,eAAO,MAAM,oBAAoB,OAAO,CAAC;AACzC,4CAA4C;AAC5C,eAAO,MAAM,eAAe,sBAAiB,CAAC;AAC9C,mGAAmG;AACnG,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,sGAAsG;AACtG,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AACtC,oFAAoF;AACpF,eAAO,MAAM,oBAAoB,QAAQ,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query-load-bearing constants for the mapper: span/event names, the severity map, scope
|
|
3
|
+
* identity, attribute namespaces, and the size caps. These are part of the telemetry contract —
|
|
4
|
+
* changing a name or a severity breaks saved queries downstream, so they live in one pinned place.
|
|
5
|
+
*/
|
|
6
|
+
// ── Scope (the instrumenting library identity) ───────────────────────────────
|
|
7
|
+
/** One constant pair for this emitter. `ScopeVersion` is injectable on the emitter for the
|
|
8
|
+
* real package version (Task 4 wiring); this is the default. */
|
|
9
|
+
export const SCOPE_NAME = "senpi.recording";
|
|
10
|
+
export const SCOPE_VERSION = "1.1.1";
|
|
11
|
+
// ── Span names (traces) ──────────────────────────────────────────────────────
|
|
12
|
+
export const SPAN_NAME = {
|
|
13
|
+
scannerRun: "scanner.run",
|
|
14
|
+
/** Root span of a signal-evaluation pass. */
|
|
15
|
+
signalPass: "signal.evaluation_pass",
|
|
16
|
+
/** One child span per evaluated signal within a pass. */
|
|
17
|
+
signalEvaluation: "signal.evaluation",
|
|
18
|
+
};
|
|
19
|
+
/** OTEL-idiomatic span event recording an error on a span. */
|
|
20
|
+
export const EXCEPTION_EVENT_NAME = "exception";
|
|
21
|
+
export const SEVERITY = {
|
|
22
|
+
INFO: { number: 9, text: "INFO" },
|
|
23
|
+
WARN: { number: 13, text: "WARN" },
|
|
24
|
+
ERROR: { number: 17, text: "ERROR" },
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Per-record/outcome severity map (deliberately not constant). Errors → ERROR; a self-pause is a
|
|
28
|
+
* WARN-worthy operational event; every other discrete event is INFO.
|
|
29
|
+
*/
|
|
30
|
+
export function severityFor(record) {
|
|
31
|
+
switch (record.type) {
|
|
32
|
+
case "runtime_error":
|
|
33
|
+
return SEVERITY.ERROR;
|
|
34
|
+
case "runtime_state":
|
|
35
|
+
return record.phase === "paused" ? SEVERITY.WARN : SEVERITY.INFO;
|
|
36
|
+
default:
|
|
37
|
+
return SEVERITY.INFO;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// ── Event names (the log-type discriminator) ─────────────────────────────────
|
|
41
|
+
/**
|
|
42
|
+
* `EventName` scheme: `{type}` for records with no sub-enum, `{type}.{discriminator}` where a
|
|
43
|
+
* discriminating enum exists — so `position_lifecycle.opened`, `dsl_transition.sl_updated`,
|
|
44
|
+
* `runtime_state.paused` are all directly filterable.
|
|
45
|
+
*/
|
|
46
|
+
export function eventNameFor(record) {
|
|
47
|
+
switch (record.type) {
|
|
48
|
+
case "position_lifecycle":
|
|
49
|
+
return `position_lifecycle.${record.event}`;
|
|
50
|
+
case "dsl_transition":
|
|
51
|
+
return `dsl_transition.${record.transition}`;
|
|
52
|
+
case "runtime_lifecycle":
|
|
53
|
+
return `runtime_lifecycle.${record.phase}`;
|
|
54
|
+
case "runtime_state":
|
|
55
|
+
return `runtime_state.${record.phase}`;
|
|
56
|
+
case "runtime_error":
|
|
57
|
+
return "runtime_error";
|
|
58
|
+
default:
|
|
59
|
+
// Trace-routed records do not carry an EventName; defensive fallback only.
|
|
60
|
+
return record.type;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Declarative trace-vs-log routing for all 7 record types. Heuristic: durationful *work units* are
|
|
65
|
+
* spans; discrete events and errors are logs. The two point-in-time domain events
|
|
66
|
+
* (`position_lifecycle`, `runtime_lifecycle`) are logs, not zero-duration spans — they carry no
|
|
67
|
+
* duration, and logs are the natural home for point-in-time events, which keeps the trace view
|
|
68
|
+
* exclusively work units. (Severity for log routes comes from {@link severityFor}.)
|
|
69
|
+
*/
|
|
70
|
+
export const ROUTING = {
|
|
71
|
+
scanner_run: { kind: "trace", spanKind: "Internal" },
|
|
72
|
+
signal_evaluated: { kind: "trace", spanKind: "Internal" },
|
|
73
|
+
position_lifecycle: { kind: "log" },
|
|
74
|
+
dsl_transition: { kind: "log" },
|
|
75
|
+
runtime_error: { kind: "log" },
|
|
76
|
+
runtime_lifecycle: { kind: "log" },
|
|
77
|
+
runtime_state: { kind: "log" },
|
|
78
|
+
};
|
|
79
|
+
// ── Wire defaults ─────────────────────────────────────────────────────────────
|
|
80
|
+
/** `1` = sampled. `0` reads as "dropped" to OTEL consumers, so always emit `1`. */
|
|
81
|
+
export const TRACE_FLAGS_SAMPLED = 1;
|
|
82
|
+
// ── Redaction ──────────────────────────────────────────────────────────────────
|
|
83
|
+
/** Replacement for a scrubbed scalar value; presence is kept, content removed. */
|
|
84
|
+
export const REDACT_MARKER = "[redacted]";
|
|
85
|
+
// ── Size caps ────────────────────────────────────────────────────────────────
|
|
86
|
+
/** Per-value character cap; longer values are truncated with {@link TRUNCATE_MARKER}. */
|
|
87
|
+
export const MAX_ATTR_VALUE_CHARS = 4096;
|
|
88
|
+
/** Marker appended to a truncated value. */
|
|
89
|
+
export const TRUNCATE_MARKER = "…[truncated]";
|
|
90
|
+
/** Max keys flattened out of a single open bag, bounding key cardinality from an unbounded bag. */
|
|
91
|
+
export const MAX_BAG_KEYS = 64;
|
|
92
|
+
/** Char cap for the single `runtime.config` JSON blob (larger than a normal value, still bounded). */
|
|
93
|
+
export const MAX_CONFIG_CHARS = 16384;
|
|
94
|
+
/** Total character budget across one row's attribute map — the total-attr guard. */
|
|
95
|
+
export const MAX_TOTAL_ATTR_CHARS = 65536;
|
|
96
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/recording/otel/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,gFAAgF;AAChF;iEACiE;AACjE,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAC5C,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC;AAErC,gFAAgF;AAChF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,UAAU,EAAE,aAAa;IACzB,6CAA6C;IAC7C,UAAU,EAAE,wBAAwB;IACpC,yDAAyD;IACzD,gBAAgB,EAAE,mBAAmB;CAC7B,CAAC;AAEX,8DAA8D;AAC9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAC;AAQhD,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;IACjC,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAClC,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;CACO,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,MAAuB;IACjD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,eAAe;YAClB,OAAO,QAAQ,CAAC,KAAK,CAAC;QACxB,KAAK,eAAe;YAClB,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,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,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC;AAE1C,gFAAgF;AAChF,yFAAyF;AACzF,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AACzC,4CAA4C;AAC5C,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC;AAC9C,mGAAmG;AACnG,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAC/B,sGAAsG;AACtG,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AACtC,oFAAoF;AACpF,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Id generation seam. The wire row shape requires a `TraceId`+`SpanId` per row, so the mapper mints
|
|
3
|
+
* them. Injecting the generator keeps the row functions pure *given their deps*, so golden
|
|
4
|
+
* `record → row` tests pass a deterministic stub. No uuid lib, no `@opentelemetry/*`.
|
|
5
|
+
*/
|
|
6
|
+
export interface IdGenerator {
|
|
7
|
+
/** 32 lowercase-hex chars (16 bytes). */
|
|
8
|
+
traceId(): string;
|
|
9
|
+
/** 16 lowercase-hex chars (8 bytes). */
|
|
10
|
+
spanId(): string;
|
|
11
|
+
}
|
|
12
|
+
/** Production generator: cryptographically-random lowercase-hex ids. */
|
|
13
|
+
export declare const cryptoIdGenerator: IdGenerator;
|
|
14
|
+
//# sourceMappingURL=ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../../src/recording/otel/ids.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,OAAO,IAAI,MAAM,CAAC;IAClB,wCAAwC;IACxC,MAAM,IAAI,MAAM,CAAC;CAClB;AAED,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,EAAE,WAG/B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Id generation seam. The wire row shape requires a `TraceId`+`SpanId` per row, so the mapper mints
|
|
3
|
+
* them. Injecting the generator keeps the row functions pure *given their deps*, so golden
|
|
4
|
+
* `record → row` tests pass a deterministic stub. No uuid lib, no `@opentelemetry/*`.
|
|
5
|
+
*/
|
|
6
|
+
import { randomBytes } from "node:crypto";
|
|
7
|
+
/** Production generator: cryptographically-random lowercase-hex ids. */
|
|
8
|
+
export const cryptoIdGenerator = {
|
|
9
|
+
traceId: () => randomBytes(16).toString("hex"),
|
|
10
|
+
spanId: () => randomBytes(8).toString("hex"),
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.js","sourceRoot":"","sources":["../../../src/recording/otel/ids.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAS1C,wEAAwE;AACxE,MAAM,CAAC,MAAM,iBAAiB,GAAgB;IAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC9C,MAAM,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;CAC7C,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `src/recording/otel/` — the mapper + {@link OtelEmitter}: domain records → HyperDX `TraceRow`/
|
|
3
|
+
* `LogRow`, then handed to the batcher. A mapper, not a span SDK (no `@opentelemetry/*`).
|
|
4
|
+
*/
|
|
5
|
+
export { OtelEmitter } from "./otel-emitter.js";
|
|
6
|
+
export type { OtelEmitterOptions } from "./otel-emitter.js";
|
|
7
|
+
export { cryptoIdGenerator } from "./ids.js";
|
|
8
|
+
export type { IdGenerator } from "./ids.js";
|
|
9
|
+
export { SCOPE_NAME, SCOPE_VERSION, SPAN_NAME, SEVERITY, ROUTING, severityFor, eventNameFor, } from "./constants.js";
|
|
10
|
+
export type { Severity, RecordRoute } from "./constants.js";
|
|
11
|
+
export { buildResource, mapScannerRun, mapSignalEvaluated, mapPositionLifecycle, mapDslTransition, mapRuntimeError, mapRuntimeLifecycle, mapRuntimeState, } from "./mappers.js";
|
|
12
|
+
export type { MapperDeps, Resource } from "./mappers.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/recording/otel/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EACL,UAAU,EACV,aAAa,EACb,SAAS,EACT,QAAQ,EACR,OAAO,EACP,WAAW,EACX,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EACL,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `src/recording/otel/` — the mapper + {@link OtelEmitter}: domain records → HyperDX `TraceRow`/
|
|
3
|
+
* `LogRow`, then handed to the batcher. A mapper, not a span SDK (no `@opentelemetry/*`).
|
|
4
|
+
*/
|
|
5
|
+
export { OtelEmitter } from "./otel-emitter.js";
|
|
6
|
+
export { cryptoIdGenerator } from "./ids.js";
|
|
7
|
+
export { SCOPE_NAME, SCOPE_VERSION, SPAN_NAME, SEVERITY, ROUTING, severityFor, eventNameFor, } from "./constants.js";
|
|
8
|
+
export { buildResource, mapScannerRun, mapSignalEvaluated, mapPositionLifecycle, mapDslTransition, mapRuntimeError, mapRuntimeLifecycle, mapRuntimeState, } from "./mappers.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/recording/otel/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,EACL,UAAU,EACV,aAAa,EACb,SAAS,EACT,QAAQ,EACR,OAAO,EACP,WAAW,EACX,YAAY,GACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,eAAe,GAChB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mapper: `RecordingRecord → TraceRow[] | LogRow[]`. Pure functions given their deps (identity,
|
|
3
|
+
* an injected {@link IdGenerator}, scope) — that is what makes the golden `record → row` tests
|
|
4
|
+
* deterministic. No `@opentelemetry/*`: this builds wire rows, it is not a span SDK.
|
|
5
|
+
*
|
|
6
|
+
* Per-record key maps and the trace-vs-log routing are pinned in {@link ./constants} and appended
|
|
7
|
+
* to the Task 2 brief. Order within a row: redact (typed-field) → flatten → cap.
|
|
8
|
+
*/
|
|
9
|
+
import type { DslTransitionRecord, IdentityEnvelope, PositionLifecycleRecord, RuntimeErrorRecord, RuntimeLifecycleRecord, RuntimeStateRecord, ScannerRunRecord, SignalEvaluatedRecord } from "../index.js";
|
|
10
|
+
import type { LogRow, TraceRow } from "../transport/index.js";
|
|
11
|
+
import type { IdGenerator } from "./ids.js";
|
|
12
|
+
/**
|
|
13
|
+
* Deps that make the row functions pure: identity envelope, the memoized resource (identity is
|
|
14
|
+
* immutable for the emitter's lifetime, so it is built once — see {@link buildResource}), the id
|
|
15
|
+
* seam, and the instrumenting scope.
|
|
16
|
+
*/
|
|
17
|
+
export interface MapperDeps {
|
|
18
|
+
readonly identity: IdentityEnvelope;
|
|
19
|
+
readonly resource: Resource;
|
|
20
|
+
readonly ids: IdGenerator;
|
|
21
|
+
readonly scopeName: string;
|
|
22
|
+
readonly scopeVersion: string;
|
|
23
|
+
}
|
|
24
|
+
export interface Resource {
|
|
25
|
+
readonly resourceAttributes: Record<string, string>;
|
|
26
|
+
readonly address: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Identity → `ResourceAttributes` (server-required `service.name` included) + the derived `address`.
|
|
30
|
+
* Built once per emitter and shared (frozen) across every row it produces. `address` is derived from
|
|
31
|
+
* `identity.strategyAddress` directly — not read back from the attribute map — so a future attr-budget
|
|
32
|
+
* edge can never silently empty the ownership/keying field.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildResource(identity: IdentityEnvelope): Resource;
|
|
35
|
+
export declare function mapScannerRun(record: ScannerRunRecord, deps: MapperDeps): TraceRow[];
|
|
36
|
+
export declare function mapSignalEvaluated(record: SignalEvaluatedRecord, deps: MapperDeps): TraceRow[];
|
|
37
|
+
export declare function mapPositionLifecycle(record: PositionLifecycleRecord, deps: MapperDeps): LogRow[];
|
|
38
|
+
export declare function mapDslTransition(record: DslTransitionRecord, deps: MapperDeps): LogRow[];
|
|
39
|
+
export declare function mapRuntimeError(record: RuntimeErrorRecord, deps: MapperDeps): LogRow[];
|
|
40
|
+
export declare function mapRuntimeLifecycle(record: RuntimeLifecycleRecord, deps: MapperDeps): LogRow[];
|
|
41
|
+
export declare function mapRuntimeState(record: RuntimeStateRecord, deps: MapperD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