@armoriq/sdk-dev 0.8.0 → 0.8.3
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/_build_env.d.ts +2 -1
- package/dist/_build_env.d.ts.map +1 -1
- package/dist/_build_env.js +4 -0
- package/dist/_build_env.js.map +1 -1
- package/dist/_version.d.ts +1 -1
- package/dist/_version.js +1 -1
- package/dist/cli/commands/auth.d.ts.map +1 -1
- package/dist/cli/commands/auth.js +68 -38
- package/dist/cli/commands/auth.js.map +1 -1
- package/dist/cli/commands/orgs.js +1 -1
- package/dist/cli/commands/orgs.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +4 -3
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +6 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/state.d.ts +3 -3
- package/dist/cli/state.d.ts.map +1 -1
- package/dist/cli/state.js +24 -12
- package/dist/cli/state.js.map +1 -1
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +26 -6
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/token_usage.d.ts +23 -0
- package/dist/token_usage.d.ts.map +1 -1
- package/dist/token_usage.js +107 -26
- package/dist/token_usage.js.map +1 -1
- package/package.json +1 -1
- package/dist/observability/handle.d.ts +0 -41
- package/dist/observability/handle.d.ts.map +0 -1
- package/dist/observability/handle.js +0 -54
- package/dist/observability/handle.js.map +0 -1
- package/dist/observability/recorder.d.ts +0 -245
- package/dist/observability/recorder.d.ts.map +0 -1
- package/dist/observability/recorder.js +0 -475
- package/dist/observability/recorder.js.map +0 -1
- package/dist/observability/schema.d.ts +0 -163
- package/dist/observability/schema.d.ts.map +0 -1
- package/dist/observability/schema.js +0 -291
- package/dist/observability/schema.js.map +0 -1
- package/dist/observability/shipper.d.ts +0 -84
- package/dist/observability/shipper.d.ts.map +0 -1
- package/dist/observability/shipper.js +0 -206
- package/dist/observability/shipper.js.map +0 -1
- package/dist/observability/trace-summary.d.ts +0 -34
- package/dist/observability/trace-summary.d.ts.map +0 -1
- package/dist/observability/trace-summary.js +0 -108
- package/dist/observability/trace-summary.js.map +0 -1
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Observability wire schema — hand-written types and runtime validators.
|
|
4
|
-
*
|
|
5
|
-
* The contract mirrors `conmap-auto/src/observability/schema.ts` (zod on the
|
|
6
|
-
* backend). The SDK cannot use zod (per plan §9 Q1) — adding it would balloon
|
|
7
|
-
* the bundle for a small, stable shape. The backend's zod parser is the
|
|
8
|
-
* safety net at the ingest boundary; if the wire shape ever drifts, the
|
|
9
|
-
* backend rejects the bad batch and the SDK's no-throw invariant swallows
|
|
10
|
-
* the warning.
|
|
11
|
-
*
|
|
12
|
-
* The validators below are deliberately cheap (typeof, structural) — they
|
|
13
|
-
* run on every emitted span and must not become a hot-path cost.
|
|
14
|
-
*/
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.isValidSpanStatus = isValidSpanStatus;
|
|
17
|
-
exports.isValidSpanKind = isValidSpanKind;
|
|
18
|
-
exports.isValidPolicyDecision = isValidPolicyDecision;
|
|
19
|
-
exports.isValidPolicySource = isValidPolicySource;
|
|
20
|
-
exports.isValidPolicyEnforcementAction = isValidPolicyEnforcementAction;
|
|
21
|
-
exports.isValidEventLevel = isValidEventLevel;
|
|
22
|
-
exports.isValidGenericSpanAttributes = isValidGenericSpanAttributes;
|
|
23
|
-
exports.isValidPolicyCallAttributes = isValidPolicyCallAttributes;
|
|
24
|
-
exports.isValidGenerationAttributes = isValidGenerationAttributes;
|
|
25
|
-
exports.isValidEventAttributes = isValidEventAttributes;
|
|
26
|
-
exports.isValidSpanAttributes = isValidSpanAttributes;
|
|
27
|
-
exports.isValidTraceRecord = isValidTraceRecord;
|
|
28
|
-
exports.isValidSpanRecord = isValidSpanRecord;
|
|
29
|
-
exports.isValidIngestBatch = isValidIngestBatch;
|
|
30
|
-
exports.isValidIngestPayload = isValidIngestPayload;
|
|
31
|
-
exports.mintId = mintId;
|
|
32
|
-
exports.isValidUuid = isValidUuid;
|
|
33
|
-
const crypto_1 = require("crypto");
|
|
34
|
-
const SPAN_KINDS = new Set([
|
|
35
|
-
'span',
|
|
36
|
-
'policy_call',
|
|
37
|
-
'generation',
|
|
38
|
-
'event',
|
|
39
|
-
]);
|
|
40
|
-
const SPAN_STATUSES = new Set(['ok', 'error', 'denied']);
|
|
41
|
-
const POLICY_DECISIONS = new Set([
|
|
42
|
-
'allow',
|
|
43
|
-
'deny',
|
|
44
|
-
'hold',
|
|
45
|
-
'ask',
|
|
46
|
-
]);
|
|
47
|
-
const POLICY_SOURCES = new Set([
|
|
48
|
-
'native',
|
|
49
|
-
'sdk-local',
|
|
50
|
-
'sdk',
|
|
51
|
-
'proxy',
|
|
52
|
-
'opa',
|
|
53
|
-
'opa_fallback',
|
|
54
|
-
]);
|
|
55
|
-
const POLICY_ENFORCEMENT_ACTIONS = new Set([
|
|
56
|
-
'allow',
|
|
57
|
-
'allow_log',
|
|
58
|
-
'hold',
|
|
59
|
-
'block',
|
|
60
|
-
]);
|
|
61
|
-
const EVENT_LEVELS = new Set(['info', 'warn', 'error']);
|
|
62
|
-
function isPlainObject(x) {
|
|
63
|
-
return typeof x === 'object' && x !== null && !Array.isArray(x);
|
|
64
|
-
}
|
|
65
|
-
// ─── Validators (cheap, return boolean) ──────────────────────────────────
|
|
66
|
-
function isValidSpanStatus(x) {
|
|
67
|
-
return typeof x === 'string' && SPAN_STATUSES.has(x);
|
|
68
|
-
}
|
|
69
|
-
function isValidSpanKind(x) {
|
|
70
|
-
return typeof x === 'string' && SPAN_KINDS.has(x);
|
|
71
|
-
}
|
|
72
|
-
function isValidPolicyDecision(x) {
|
|
73
|
-
return typeof x === 'string' && POLICY_DECISIONS.has(x);
|
|
74
|
-
}
|
|
75
|
-
function isValidPolicySource(x) {
|
|
76
|
-
return typeof x === 'string' && POLICY_SOURCES.has(x);
|
|
77
|
-
}
|
|
78
|
-
function isValidPolicyEnforcementAction(x) {
|
|
79
|
-
return (typeof x === 'string' && POLICY_ENFORCEMENT_ACTIONS.has(x));
|
|
80
|
-
}
|
|
81
|
-
function isValidEventLevel(x) {
|
|
82
|
-
return typeof x === 'string' && EVENT_LEVELS.has(x);
|
|
83
|
-
}
|
|
84
|
-
function isStringOrNull(x) {
|
|
85
|
-
return x === null || typeof x === 'string';
|
|
86
|
-
}
|
|
87
|
-
function isStringArrayOrEmpty(x) {
|
|
88
|
-
return Array.isArray(x) && x.every((v) => typeof v === 'string');
|
|
89
|
-
}
|
|
90
|
-
function isValidGenericSpanAttributes(x) {
|
|
91
|
-
if (!isPlainObject(x))
|
|
92
|
-
return false;
|
|
93
|
-
if (x.kind !== 'span')
|
|
94
|
-
return false;
|
|
95
|
-
if ('toolName' in x &&
|
|
96
|
-
x.toolName !== undefined &&
|
|
97
|
-
typeof x.toolName !== 'string')
|
|
98
|
-
return false;
|
|
99
|
-
if ('errorMessage' in x &&
|
|
100
|
-
x.errorMessage !== undefined &&
|
|
101
|
-
typeof x.errorMessage !== 'string')
|
|
102
|
-
return false;
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
function isValidPolicyCallAttributes(x) {
|
|
106
|
-
if (!isPlainObject(x))
|
|
107
|
-
return false;
|
|
108
|
-
if (x.kind !== 'policy_call')
|
|
109
|
-
return false;
|
|
110
|
-
if (!isValidPolicyDecision(x.decision))
|
|
111
|
-
return false;
|
|
112
|
-
if (!isValidPolicySource(x.source))
|
|
113
|
-
return false;
|
|
114
|
-
if (!isStringOrNull(x.policyId))
|
|
115
|
-
return false;
|
|
116
|
-
if (!isStringOrNull(x.policyName))
|
|
117
|
-
return false;
|
|
118
|
-
if (!isStringOrNull(x.policyHash))
|
|
119
|
-
return false;
|
|
120
|
-
if (!isStringOrNull(x.policyVersion))
|
|
121
|
-
return false;
|
|
122
|
-
if (!isStringOrNull(x.matchedRuleId))
|
|
123
|
-
return false;
|
|
124
|
-
if (!isStringOrNull(x.reason))
|
|
125
|
-
return false;
|
|
126
|
-
if (!isStringOrNull(x.delegationId))
|
|
127
|
-
return false;
|
|
128
|
-
if (!isStringArrayOrEmpty(x.dataClasses))
|
|
129
|
-
return false;
|
|
130
|
-
if ('enforcementAction' in x &&
|
|
131
|
-
x.enforcementAction !== null &&
|
|
132
|
-
!isValidPolicyEnforcementAction(x.enforcementAction))
|
|
133
|
-
return false;
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
function isValidGenerationAttributes(x) {
|
|
137
|
-
if (!isPlainObject(x))
|
|
138
|
-
return false;
|
|
139
|
-
if (x.kind !== 'generation')
|
|
140
|
-
return false;
|
|
141
|
-
if (typeof x.model !== 'string')
|
|
142
|
-
return false;
|
|
143
|
-
if (typeof x.inputTokens !== 'number' || !Number.isFinite(x.inputTokens))
|
|
144
|
-
return false;
|
|
145
|
-
if (typeof x.outputTokens !== 'number' || !Number.isFinite(x.outputTokens))
|
|
146
|
-
return false;
|
|
147
|
-
if (typeof x.costUsd !== 'number' || !Number.isFinite(x.costUsd))
|
|
148
|
-
return false;
|
|
149
|
-
if ('cacheReadTokens' in x &&
|
|
150
|
-
x.cacheReadTokens !== null &&
|
|
151
|
-
(typeof x.cacheReadTokens !== 'number' || !Number.isFinite(x.cacheReadTokens)))
|
|
152
|
-
return false;
|
|
153
|
-
if ('cacheWriteTokens' in x &&
|
|
154
|
-
x.cacheWriteTokens !== null &&
|
|
155
|
-
(typeof x.cacheWriteTokens !== 'number' || !Number.isFinite(x.cacheWriteTokens)))
|
|
156
|
-
return false;
|
|
157
|
-
if ('prompt' in x && x.prompt !== null && typeof x.prompt !== 'string')
|
|
158
|
-
return false;
|
|
159
|
-
if ('completion' in x &&
|
|
160
|
-
x.completion !== null &&
|
|
161
|
-
typeof x.completion !== 'string')
|
|
162
|
-
return false;
|
|
163
|
-
if ('finishReason' in x &&
|
|
164
|
-
x.finishReason !== null &&
|
|
165
|
-
typeof x.finishReason !== 'string')
|
|
166
|
-
return false;
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
function isValidEventAttributes(x) {
|
|
170
|
-
if (!isPlainObject(x))
|
|
171
|
-
return false;
|
|
172
|
-
if (x.kind !== 'event')
|
|
173
|
-
return false;
|
|
174
|
-
if (typeof x.message !== 'string')
|
|
175
|
-
return false;
|
|
176
|
-
return isValidEventLevel(x.level);
|
|
177
|
-
}
|
|
178
|
-
function isValidSpanAttributes(x) {
|
|
179
|
-
if (!isPlainObject(x))
|
|
180
|
-
return false;
|
|
181
|
-
const k = x.kind;
|
|
182
|
-
if (k === 'span')
|
|
183
|
-
return isValidGenericSpanAttributes(x);
|
|
184
|
-
if (k === 'policy_call')
|
|
185
|
-
return isValidPolicyCallAttributes(x);
|
|
186
|
-
if (k === 'generation')
|
|
187
|
-
return isValidGenerationAttributes(x);
|
|
188
|
-
if (k === 'event')
|
|
189
|
-
return isValidEventAttributes(x);
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
function isValidTraceRecord(x) {
|
|
193
|
-
if (!isPlainObject(x))
|
|
194
|
-
return false;
|
|
195
|
-
if (typeof x.id !== 'string' || x.id.length === 0)
|
|
196
|
-
return false;
|
|
197
|
-
if (typeof x.name !== 'string' || x.name.length === 0)
|
|
198
|
-
return false;
|
|
199
|
-
if (typeof x.startTime !== 'string')
|
|
200
|
-
return false;
|
|
201
|
-
if ('endTime' in x &&
|
|
202
|
-
x.endTime !== null &&
|
|
203
|
-
typeof x.endTime !== 'string')
|
|
204
|
-
return false;
|
|
205
|
-
if ('durationMs' in x &&
|
|
206
|
-
x.durationMs !== null &&
|
|
207
|
-
(typeof x.durationMs !== 'number' || !Number.isInteger(x.durationMs)))
|
|
208
|
-
return false;
|
|
209
|
-
if (!isValidSpanStatus(x.status))
|
|
210
|
-
return false;
|
|
211
|
-
if (!isStringOrNull(x.sessionId))
|
|
212
|
-
return false;
|
|
213
|
-
if (!isStringOrNull(x.userId))
|
|
214
|
-
return false;
|
|
215
|
-
if (!isStringOrNull(x.agentId))
|
|
216
|
-
return false;
|
|
217
|
-
if (!isPlainObject(x.attributes))
|
|
218
|
-
return false;
|
|
219
|
-
if (!isStringArrayOrEmpty(x.tags))
|
|
220
|
-
return false;
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
function isValidSpanRecord(x) {
|
|
224
|
-
if (!isPlainObject(x))
|
|
225
|
-
return false;
|
|
226
|
-
if (typeof x.id !== 'string' || x.id.length === 0)
|
|
227
|
-
return false;
|
|
228
|
-
if (typeof x.name !== 'string' || x.name.length === 0)
|
|
229
|
-
return false;
|
|
230
|
-
if (typeof x.startTime !== 'string')
|
|
231
|
-
return false;
|
|
232
|
-
if ('endTime' in x &&
|
|
233
|
-
x.endTime !== null &&
|
|
234
|
-
typeof x.endTime !== 'string')
|
|
235
|
-
return false;
|
|
236
|
-
if ('durationMs' in x &&
|
|
237
|
-
x.durationMs !== null &&
|
|
238
|
-
(typeof x.durationMs !== 'number' || !Number.isInteger(x.durationMs)))
|
|
239
|
-
return false;
|
|
240
|
-
if (!isValidSpanKind(x.kind))
|
|
241
|
-
return false;
|
|
242
|
-
if (!isValidSpanStatus(x.status))
|
|
243
|
-
return false;
|
|
244
|
-
if (!isStringOrNull(x.parentSpanId))
|
|
245
|
-
return false;
|
|
246
|
-
if (!isStringOrNull(x.sessionId))
|
|
247
|
-
return false;
|
|
248
|
-
return isValidSpanAttributes(x.attributes);
|
|
249
|
-
}
|
|
250
|
-
function isValidIngestBatch(x) {
|
|
251
|
-
if (!isPlainObject(x))
|
|
252
|
-
return false;
|
|
253
|
-
if (!isValidTraceRecord(x.trace))
|
|
254
|
-
return false;
|
|
255
|
-
if (!Array.isArray(x.spans))
|
|
256
|
-
return false;
|
|
257
|
-
for (const s of x.spans) {
|
|
258
|
-
if (!isValidSpanRecord(s))
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
return true;
|
|
262
|
-
}
|
|
263
|
-
function isValidIngestPayload(x) {
|
|
264
|
-
if (!isPlainObject(x))
|
|
265
|
-
return false;
|
|
266
|
-
if (typeof x.product !== 'string' || x.product.length === 0)
|
|
267
|
-
return false;
|
|
268
|
-
if (!isStringOrNull(x.sessionId))
|
|
269
|
-
return false;
|
|
270
|
-
if (!Array.isArray(x.batches) || x.batches.length === 0)
|
|
271
|
-
return false;
|
|
272
|
-
for (const b of x.batches) {
|
|
273
|
-
if (!isValidIngestBatch(b))
|
|
274
|
-
return false;
|
|
275
|
-
}
|
|
276
|
-
return true;
|
|
277
|
-
}
|
|
278
|
-
// ─── ID minting helper (used by recorder) ────────────────────────────────
|
|
279
|
-
function mintId() {
|
|
280
|
-
return (0, crypto_1.randomUUID)();
|
|
281
|
-
}
|
|
282
|
-
// ─── UUID validation ──────────────────────────────────────────────────────
|
|
283
|
-
// The backend's `obs_sessions.id` column is a UUID. A trace's `sessionId`
|
|
284
|
-
// must therefore either be a valid UUID or `null` — never an arbitrary
|
|
285
|
-
// string like the literal `'default'` — or the trace can never be grouped
|
|
286
|
-
// into a session (see ArmorIQSession's sessionId resolution in session.ts).
|
|
287
|
-
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
288
|
-
function isValidUuid(x) {
|
|
289
|
-
return typeof x === 'string' && UUID_RE.test(x);
|
|
290
|
-
}
|
|
291
|
-
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/observability/schema.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAqNH,8CAEC;AAED,0CAEC;AAED,sDAEC;AAED,kDAEC;AAED,w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
* ObservabilityShipper — batches ended traces + their spans and POSTs them
|
|
3
|
-
* to the backend ingest endpoint.
|
|
4
|
-
*
|
|
5
|
-
* Failure handling (the no-throw invariant):
|
|
6
|
-
* - 4xx: log warning, drop the batches. The backend has rejected the
|
|
7
|
-
* payload as malformed; retrying won't help.
|
|
8
|
-
* - 5xx and network errors: exponential backoff (500ms, 1s, 2s) up to
|
|
9
|
-
* 3 retries; then log warning, drop.
|
|
10
|
-
* - Any throw from the httpClient is caught and treated as a network
|
|
11
|
-
* error (retried per the same schedule).
|
|
12
|
-
*
|
|
13
|
-
* The shipper is owned by `ObservabilityRecorder` — SDK consumers should
|
|
14
|
-
* not construct it directly. It's exported so the recorder module can
|
|
15
|
-
* import it without circular dep issues.
|
|
16
|
-
*/
|
|
17
|
-
import { AxiosInstance } from 'axios';
|
|
18
|
-
import { type IngestBatch } from './schema';
|
|
19
|
-
export interface ShipperConfig {
|
|
20
|
-
/** Backend base URL (no trailing slash). Shipper appends `/observability/spans`. */
|
|
21
|
-
endpoint: string;
|
|
22
|
-
/** API key sent in the `X-API-Key` header. */
|
|
23
|
-
apiKey: string;
|
|
24
|
-
/** Product tag included in every payload. */
|
|
25
|
-
product: string;
|
|
26
|
-
/** Optional top-level session id (used as the fallback for batches without one). */
|
|
27
|
-
sessionId?: string | null;
|
|
28
|
-
/**
|
|
29
|
-
* Max batches per POST. Default 100. `flush()` chunks the queue into
|
|
30
|
-
* groups of at most this size and sends one POST per chunk — a burst of
|
|
31
|
-
* traces never sends a single unbounded giant POST.
|
|
32
|
-
*/
|
|
33
|
-
batchSize?: number;
|
|
34
|
-
/** Auto-flush interval (ms). Default 5000. */
|
|
35
|
-
flushIntervalMs?: number;
|
|
36
|
-
/** Override the HTTP client (axios instance). Defaults to axios.create({ timeout: 10000 }). */
|
|
37
|
-
httpClient?: AxiosInstance;
|
|
38
|
-
}
|
|
39
|
-
export declare class ObservabilityShipper {
|
|
40
|
-
private readonly endpoint;
|
|
41
|
-
private readonly apiKey;
|
|
42
|
-
private readonly product;
|
|
43
|
-
private readonly sessionId;
|
|
44
|
-
private readonly batchSize;
|
|
45
|
-
private readonly flushIntervalMs;
|
|
46
|
-
private readonly httpClient;
|
|
47
|
-
private readonly queue;
|
|
48
|
-
private intervalHandle;
|
|
49
|
-
private stopPromise;
|
|
50
|
-
constructor(config: ShipperConfig);
|
|
51
|
-
/**
|
|
52
|
-
* Append a batch to the internal queue. The shipper does not validate
|
|
53
|
-
* the batch here (the recorder already validates on record); invalid
|
|
54
|
-
* batches are filtered at flush time.
|
|
55
|
-
*/
|
|
56
|
-
enqueue(batch: IngestBatch): void;
|
|
57
|
-
/**
|
|
58
|
-
* Start the periodic auto-flush. Idempotent — calling start() while
|
|
59
|
-
* already running is a no-op.
|
|
60
|
-
*/
|
|
61
|
-
start(): void;
|
|
62
|
-
/**
|
|
63
|
-
* Stop the periodic auto-flush and do a final flush of anything still
|
|
64
|
-
* in the queue. Safe to call multiple times.
|
|
65
|
-
*/
|
|
66
|
-
stop(): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* POST all queued batches, chunked so each POST carries at most
|
|
69
|
-
* `this.batchSize` batches (default 100) — a burst of traces no longer
|
|
70
|
-
* sends one unbounded giant POST. Chunks are sent sequentially (simpler
|
|
71
|
-
* failure semantics than parallel: a failing chunk doesn't race with a
|
|
72
|
-
* later chunk's retry backoff). Returns the summed `{ accepted, rejected }`
|
|
73
|
-
* across all chunks. NEVER throws — observability failures must not break
|
|
74
|
-
* the consumer.
|
|
75
|
-
*/
|
|
76
|
-
flush(): Promise<{
|
|
77
|
-
accepted: number;
|
|
78
|
-
rejected: number;
|
|
79
|
-
}>;
|
|
80
|
-
/** Test-only accessor: inspect the current queue size. */
|
|
81
|
-
get __queueSize(): number;
|
|
82
|
-
private postWithRetry;
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=shipper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shipper.d.ts","sourceRoot":"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QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAiC9D,0DAA0D;IAC1D,IAAI,WAAW,IAAI,MAAM,CAExB;YAIa,aAAa;CA+C5B"}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ObservabilityShipper — batches ended traces + their spans and POSTs them
|
|
4
|
-
* to the backend ingest endpoint.
|
|
5
|
-
*
|
|
6
|
-
* Failure handling (the no-throw invariant):
|
|
7
|
-
* - 4xx: log warning, drop the batches. The backend has rejected the
|
|
8
|
-
* payload as malformed; retrying won't help.
|
|
9
|
-
* - 5xx and network errors: exponential backoff (500ms, 1s, 2s) up to
|
|
10
|
-
* 3 retries; then log warning, drop.
|
|
11
|
-
* - Any throw from the httpClient is caught and treated as a network
|
|
12
|
-
* error (retried per the same schedule).
|
|
13
|
-
*
|
|
14
|
-
* The shipper is owned by `ObservabilityRecorder` — SDK consumers should
|
|
15
|
-
* not construct it directly. It's exported so the recorder module can
|
|
16
|
-
* import it without circular dep issues.
|
|
17
|
-
*/
|
|
18
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.ObservabilityShipper = void 0;
|
|
23
|
-
const axios_1 = __importDefault(require("axios"));
|
|
24
|
-
const crypto_1 = require("crypto");
|
|
25
|
-
const schema_1 = require("./schema");
|
|
26
|
-
const DEFAULT_BATCH_SIZE = 100;
|
|
27
|
-
const DEFAULT_FLUSH_INTERVAL_MS = 5000;
|
|
28
|
-
const MAX_RETRIES = 3;
|
|
29
|
-
const BACKOFF_BASE_MS = 500;
|
|
30
|
-
const HTTP_TIMEOUT_MS = 10000;
|
|
31
|
-
function sleep(ms) {
|
|
32
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
33
|
-
}
|
|
34
|
-
/** Split `batches` into chunks of at most `size` batches each (size >= 1). */
|
|
35
|
-
function chunkBatches(batches, size) {
|
|
36
|
-
const effectiveSize = size > 0 ? size : DEFAULT_BATCH_SIZE;
|
|
37
|
-
const chunks = [];
|
|
38
|
-
for (let i = 0; i < batches.length; i += effectiveSize) {
|
|
39
|
-
chunks.push(batches.slice(i, i + effectiveSize));
|
|
40
|
-
}
|
|
41
|
-
return chunks;
|
|
42
|
-
}
|
|
43
|
-
// ─── beforeExit singleton ──────────────────────────────────────────────────
|
|
44
|
-
// Each shipper registers itself here on start(). A single beforeExit listener
|
|
45
|
-
// drains all active shippers so we never leak listeners (Node warns at 11).
|
|
46
|
-
const activeShippers = new Set();
|
|
47
|
-
let beforeExitRegistered = false;
|
|
48
|
-
function registerBeforeExitHandler() {
|
|
49
|
-
if (beforeExitRegistered)
|
|
50
|
-
return;
|
|
51
|
-
if (typeof process === 'undefined' || typeof process.on !== 'function')
|
|
52
|
-
return;
|
|
53
|
-
beforeExitRegistered = true;
|
|
54
|
-
process.on('beforeExit', () => {
|
|
55
|
-
for (const s of activeShippers) {
|
|
56
|
-
void s.stop();
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
class ObservabilityShipper {
|
|
61
|
-
endpoint;
|
|
62
|
-
apiKey;
|
|
63
|
-
product;
|
|
64
|
-
sessionId;
|
|
65
|
-
batchSize;
|
|
66
|
-
flushIntervalMs;
|
|
67
|
-
httpClient;
|
|
68
|
-
queue = [];
|
|
69
|
-
intervalHandle = null;
|
|
70
|
-
stopPromise = null;
|
|
71
|
-
constructor(config) {
|
|
72
|
-
this.endpoint = config.endpoint.replace(/\/+$/, '');
|
|
73
|
-
this.apiKey = config.apiKey;
|
|
74
|
-
this.product = config.product;
|
|
75
|
-
this.sessionId = config.sessionId ?? null;
|
|
76
|
-
this.batchSize = config.batchSize ?? DEFAULT_BATCH_SIZE;
|
|
77
|
-
this.flushIntervalMs = config.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS;
|
|
78
|
-
this.httpClient =
|
|
79
|
-
config.httpClient ?? axios_1.default.create({ timeout: HTTP_TIMEOUT_MS });
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Append a batch to the internal queue. The shipper does not validate
|
|
83
|
-
* the batch here (the recorder already validates on record); invalid
|
|
84
|
-
* batches are filtered at flush time.
|
|
85
|
-
*/
|
|
86
|
-
enqueue(batch) {
|
|
87
|
-
this.queue.push(batch);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Start the periodic auto-flush. Idempotent — calling start() while
|
|
91
|
-
* already running is a no-op.
|
|
92
|
-
*/
|
|
93
|
-
start() {
|
|
94
|
-
if (this.intervalHandle)
|
|
95
|
-
return;
|
|
96
|
-
this.intervalHandle = setInterval(() => {
|
|
97
|
-
void this.flush();
|
|
98
|
-
}, this.flushIntervalMs);
|
|
99
|
-
if (typeof this.intervalHandle === 'object' && this.intervalHandle !== null) {
|
|
100
|
-
// Don't keep the event loop alive solely for the flush interval.
|
|
101
|
-
this.intervalHandle.unref?.();
|
|
102
|
-
}
|
|
103
|
-
activeShippers.add(this);
|
|
104
|
-
registerBeforeExitHandler();
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Stop the periodic auto-flush and do a final flush of anything still
|
|
108
|
-
* in the queue. Safe to call multiple times.
|
|
109
|
-
*/
|
|
110
|
-
stop() {
|
|
111
|
-
if (this.stopPromise)
|
|
112
|
-
return this.stopPromise;
|
|
113
|
-
activeShippers.delete(this);
|
|
114
|
-
this.stopPromise = (async () => {
|
|
115
|
-
if (this.intervalHandle) {
|
|
116
|
-
clearInterval(this.intervalHandle);
|
|
117
|
-
this.intervalHandle = null;
|
|
118
|
-
}
|
|
119
|
-
await this.flush();
|
|
120
|
-
})();
|
|
121
|
-
return this.stopPromise;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* POST all queued batches, chunked so each POST carries at most
|
|
125
|
-
* `this.batchSize` batches (default 100) — a burst of traces no longer
|
|
126
|
-
* sends one unbounded giant POST. Chunks are sent sequentially (simpler
|
|
127
|
-
* failure semantics than parallel: a failing chunk doesn't race with a
|
|
128
|
-
* later chunk's retry backoff). Returns the summed `{ accepted, rejected }`
|
|
129
|
-
* across all chunks. NEVER throws — observability failures must not break
|
|
130
|
-
* the consumer.
|
|
131
|
-
*/
|
|
132
|
-
async flush() {
|
|
133
|
-
if (this.queue.length === 0) {
|
|
134
|
-
return { accepted: 0, rejected: 0 };
|
|
135
|
-
}
|
|
136
|
-
// Snapshot the queue and clear it before the network call so a
|
|
137
|
-
// concurrent enqueue lands in the next flush.
|
|
138
|
-
const batches = this.queue.splice(0, this.queue.length);
|
|
139
|
-
const valid = batches.filter((b) => (0, schema_1.isValidIngestBatch)(b));
|
|
140
|
-
const invalid = batches.length - valid.length;
|
|
141
|
-
if (invalid > 0) {
|
|
142
|
-
// eslint-disable-next-line no-console
|
|
143
|
-
console.warn(`[observability] shipper dropped ${invalid} invalid batch(es) at flush`);
|
|
144
|
-
}
|
|
145
|
-
if (valid.length === 0) {
|
|
146
|
-
return { accepted: 0, rejected: invalid };
|
|
147
|
-
}
|
|
148
|
-
let accepted = 0;
|
|
149
|
-
let rejected = invalid;
|
|
150
|
-
for (const chunk of chunkBatches(valid, this.batchSize)) {
|
|
151
|
-
const payload = {
|
|
152
|
-
product: this.product,
|
|
153
|
-
sessionId: this.sessionId,
|
|
154
|
-
batches: chunk,
|
|
155
|
-
};
|
|
156
|
-
const result = await this.postWithRetry(payload);
|
|
157
|
-
accepted += result.accepted;
|
|
158
|
-
rejected += result.rejected;
|
|
159
|
-
}
|
|
160
|
-
return { accepted, rejected };
|
|
161
|
-
}
|
|
162
|
-
/** Test-only accessor: inspect the current queue size. */
|
|
163
|
-
get __queueSize() {
|
|
164
|
-
return this.queue.length;
|
|
165
|
-
}
|
|
166
|
-
// ─── Internals ────────────────────────────────────────────────────────
|
|
167
|
-
async postWithRetry(payload) {
|
|
168
|
-
const url = `${this.endpoint}/observability/spans`;
|
|
169
|
-
const headers = {
|
|
170
|
-
'X-API-Key': this.apiKey,
|
|
171
|
-
'Content-Type': 'application/json',
|
|
172
|
-
'X-Request-Id': (0, crypto_1.randomUUID)(),
|
|
173
|
-
};
|
|
174
|
-
let lastError = null;
|
|
175
|
-
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
176
|
-
try {
|
|
177
|
-
const response = await this.httpClient.post(url, payload, { headers });
|
|
178
|
-
const status = response.status;
|
|
179
|
-
if (status >= 200 && status < 300) {
|
|
180
|
-
const data = (response.data ?? {});
|
|
181
|
-
return {
|
|
182
|
-
accepted: typeof data.accepted === 'number' ? data.accepted : 0,
|
|
183
|
-
rejected: typeof data.rejected === 'number' ? data.rejected : 0,
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
if (status >= 400 && status < 500) {
|
|
187
|
-
// eslint-disable-next-line no-console
|
|
188
|
-
console.warn(`[observability] shipper got ${status} from ${url}; dropping ${payload.batches.length} batch(es)`);
|
|
189
|
-
return { accepted: 0, rejected: payload.batches.length };
|
|
190
|
-
}
|
|
191
|
-
lastError = new Error(`HTTP ${status}`);
|
|
192
|
-
}
|
|
193
|
-
catch (e) {
|
|
194
|
-
lastError = e;
|
|
195
|
-
}
|
|
196
|
-
if (attempt < MAX_RETRIES) {
|
|
197
|
-
await sleep(BACKOFF_BASE_MS * 2 ** attempt);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
// eslint-disable-next-line no-console
|
|
201
|
-
console.warn(`[observability] shipper failed after ${MAX_RETRIES} retries; dropping ${payload.batches.length} batch(es): ${lastError?.message ?? 'unknown error'}`);
|
|
202
|
-
return { accepted: 0, rejected: payload.batches.length };
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
exports.ObservabilityShipper = ObservabilityShipper;
|
|
206
|
-
//# sourceMappingURL=shipper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version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AS,GAAG,CAAC,CAAC;YAChB,CAAC;YACD,IAAI,OAAO,GAAG,WAAW,EAAE,CAAC;gBAC1B,MAAM,KAAK,CAAC,eAAe,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QACD,sCAAsC;QACtC,OAAO,CAAC,IAAI,CACV,wCAAwC,WAAW,sBAAsB,OAAO,CAAC,OAAO,CAAC,MAAM,eAC5F,SAAmB,EAAE,OAAO,IAAI,eACnC,EAAE,CACH,CAAC;QACF,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC3D,CAAC;CACF;AAlKD,oDAkKC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trace-level tag/output-summary derivation.
|
|
3
|
-
*
|
|
4
|
-
* A trace's own `tags`/`attributes.output` are never populated by callers
|
|
5
|
-
* today (every chokepoint only passes freeform `attributes` at
|
|
6
|
-
* `startTrace()` time, before any child span exists) — so without this
|
|
7
|
-
* module every trace ships with `tags: []` and no output summary, even
|
|
8
|
-
* though the information needed to compute both already lives on the
|
|
9
|
-
* trace's own spans by the time `endTrace()` runs.
|
|
10
|
-
*
|
|
11
|
-
* This is intentionally derived, not caller-supplied: it's computed once,
|
|
12
|
-
* in one place (`ObservabilityRecorder.endTrace`), from the same in-memory
|
|
13
|
-
* `spans` array the recorder already holds — no new public API surface,
|
|
14
|
-
* no risk of callers drifting from each other's tagging conventions.
|
|
15
|
-
*
|
|
16
|
-
* Kept deliberately conservative and low-cardinality (per the dashboard's
|
|
17
|
-
* TAGS column contract): product + distinct tool names + one decision
|
|
18
|
-
* verdict, nothing free-text or unbounded.
|
|
19
|
-
*/
|
|
20
|
-
import type { SpanRecord } from './schema';
|
|
21
|
-
export interface TraceSummary {
|
|
22
|
-
/** Low-cardinality tags: product + distinct tool names + decision verdict. */
|
|
23
|
-
tags: string[];
|
|
24
|
-
/** Concise outcome summary derived from policy_call spans, or null if none. */
|
|
25
|
-
output: string | null;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Derive `{ tags, output }` for a trace from its accumulated spans. Pure
|
|
29
|
-
* and read-only — never mutates `spans`. Callers merge the result onto the
|
|
30
|
-
* trace record themselves (see `ObservabilityRecorder.endTrace`), preserving
|
|
31
|
-
* any tags/output the caller already set explicitly.
|
|
32
|
-
*/
|
|
33
|
-
export declare function deriveTraceSummary(spans: readonly SpanRecord[], product: string | null | undefined): TraceSummary;
|
|
34
|
-
//# sourceMappingURL=trace-summary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trace-summary.d.ts","sourceRoot":"","sources":["../../src/observability/trace-summary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAwB,UAAU,EAAE,MAAM,UAAU,CAAC;AAqEjE,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,+EAA+E;IAC/E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACjC,YAAY,CAad"}
|