agentfootprint 2.8.2 → 2.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/adapters/observability/xray.js +370 -0
- package/dist/adapters/observability/xray.js.map +1 -0
- package/dist/esm/adapters/observability/xray.js +366 -0
- package/dist/esm/adapters/observability/xray.js.map +1 -0
- package/dist/esm/observability-providers.js +3 -2
- package/dist/esm/observability-providers.js.map +1 -1
- package/dist/observability-providers.js +5 -3
- package/dist/observability-providers.js.map +1 -1
- package/dist/types/adapters/observability/xray.d.ts +83 -0
- package/dist/types/adapters/observability/xray.d.ts.map +1 -0
- package/dist/types/observability-providers.d.ts +3 -2
- package/dist/types/observability-providers.d.ts.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* xrayObservability — AWS X-Ray distributed-tracing adapter.
|
|
4
|
+
*
|
|
5
|
+
* Maps agentfootprint's event taxonomy onto AWS X-Ray segment trees:
|
|
6
|
+
*
|
|
7
|
+
* agent.turn_start ↦ root segment (one trace per turn)
|
|
8
|
+
* agent.turn_end ↦ close root segment + flush
|
|
9
|
+
* agent.iteration_start ↦ push subsegment under root
|
|
10
|
+
* agent.iteration_end ↦ close iteration subsegment
|
|
11
|
+
* stream.llm_start ↦ push leaf subsegment (model call)
|
|
12
|
+
* stream.llm_end ↦ close llm subsegment
|
|
13
|
+
* stream.tool_start ↦ push leaf subsegment (tool call)
|
|
14
|
+
* stream.tool_end ↦ close tool subsegment
|
|
15
|
+
*
|
|
16
|
+
* The result in the X-Ray Trace Map: a hierarchical timeline of every
|
|
17
|
+
* agent run — turn → iteration → llm-call/tool-call — queryable in
|
|
18
|
+
* X-Ray Insights, joinable with the rest of your AWS distributed
|
|
19
|
+
* trace via `AWSTraceHeader` propagation (consumer's responsibility
|
|
20
|
+
* to wire upstream/downstream IDs).
|
|
21
|
+
*
|
|
22
|
+
* Subpath: `agentfootprint/observability-providers`
|
|
23
|
+
* Peer dep: `@aws-sdk/client-xray` (OPTIONAL — installed only when
|
|
24
|
+
* this adapter is used).
|
|
25
|
+
*
|
|
26
|
+
* Sampling:
|
|
27
|
+
* By default every turn produces one trace. Pass `sampleRate: 0.1`
|
|
28
|
+
* to sample 10% of turns — sampling decisions are made at
|
|
29
|
+
* `turn_start` and persist for the whole turn (so partial traces
|
|
30
|
+
* never reach X-Ray).
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { xrayObservability } from 'agentfootprint/observability-providers';
|
|
35
|
+
* import { microtaskBatchDriver } from 'footprintjs/detach';
|
|
36
|
+
*
|
|
37
|
+
* agent.enable.observability({
|
|
38
|
+
* strategy: xrayObservability({
|
|
39
|
+
* region: 'us-east-1',
|
|
40
|
+
* serviceName: 'my-agent',
|
|
41
|
+
* sampleRate: 0.1, // 10% sampling
|
|
42
|
+
* }),
|
|
43
|
+
* detach: { driver: microtaskBatchDriver, mode: 'forget' },
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example Test injection
|
|
48
|
+
* ```ts
|
|
49
|
+
* xrayObservability({
|
|
50
|
+
* serviceName: 'test',
|
|
51
|
+
* _client: {
|
|
52
|
+
* putTraceSegments: async (input) => { capturedDocs.push(input); },
|
|
53
|
+
* },
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
+
exports.xrayObservability = void 0;
|
|
59
|
+
const lazyRequire_js_1 = require("../../lib/lazyRequire.js");
|
|
60
|
+
// ─── Strategy factory ────────────────────────────────────────────────
|
|
61
|
+
function xrayObservability(opts) {
|
|
62
|
+
if (!opts.serviceName) {
|
|
63
|
+
throw new TypeError(`[xrayObservability] \`serviceName\` is required. ` +
|
|
64
|
+
`Pass an identifier visible in your X-Ray service map, e.g. 'my-agent-prod'.`);
|
|
65
|
+
}
|
|
66
|
+
const sampleRate = opts.sampleRate ?? 1;
|
|
67
|
+
const maxBatchSegments = opts.maxBatchSegments ?? 25;
|
|
68
|
+
const flushIntervalMs = opts.flushIntervalMs ?? 1000;
|
|
69
|
+
// Per-turn state. agentfootprint events arrive interleaved across
|
|
70
|
+
// multiple in-flight turns; we key the active stack by `runId`
|
|
71
|
+
// (every event payload carries it after enrichment).
|
|
72
|
+
const activeTurns = new Map();
|
|
73
|
+
// Outbound segment buffer (flat list of closed segments ready for
|
|
74
|
+
// PutTraceSegments). Drained by flush() / size-trigger / time-trigger.
|
|
75
|
+
const outbox = [];
|
|
76
|
+
let lastFlushPromise = Promise.resolve();
|
|
77
|
+
let timer;
|
|
78
|
+
let stopped = false;
|
|
79
|
+
let onErrorHook;
|
|
80
|
+
// Lazy SDK client.
|
|
81
|
+
let client = opts._client;
|
|
82
|
+
function ensureClient() {
|
|
83
|
+
if (client)
|
|
84
|
+
return client;
|
|
85
|
+
client = createXRayClient(opts.region);
|
|
86
|
+
return client;
|
|
87
|
+
}
|
|
88
|
+
function scheduleTimedFlush() {
|
|
89
|
+
if (timer || flushIntervalMs <= 0 || stopped)
|
|
90
|
+
return;
|
|
91
|
+
timer = setTimeout(() => {
|
|
92
|
+
timer = undefined;
|
|
93
|
+
void doFlush();
|
|
94
|
+
}, flushIntervalMs);
|
|
95
|
+
}
|
|
96
|
+
async function doFlush() {
|
|
97
|
+
if (outbox.length === 0 || stopped)
|
|
98
|
+
return;
|
|
99
|
+
const batch = outbox.splice(0, maxBatchSegments);
|
|
100
|
+
try {
|
|
101
|
+
await ensureClient().putTraceSegments({
|
|
102
|
+
TraceSegmentDocuments: batch.map((s) => JSON.stringify(s)),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
onErrorHook?.(err instanceof Error ? err : new Error(String(err)));
|
|
107
|
+
}
|
|
108
|
+
// If outbox grew during the put (size > maxBatchSegments emits
|
|
109
|
+
// arrived), chain another flush.
|
|
110
|
+
if (outbox.length > 0 && !stopped) {
|
|
111
|
+
lastFlushPromise = lastFlushPromise.then(doFlush, doFlush);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function pushSegment(turnState, name) {
|
|
115
|
+
const parent = turnState.stack[turnState.stack.length - 1];
|
|
116
|
+
const seg = {
|
|
117
|
+
name,
|
|
118
|
+
id: hexId(16),
|
|
119
|
+
trace_id: turnState.traceId,
|
|
120
|
+
...(parent && { parent_id: parent.id }),
|
|
121
|
+
start_time: nowSeconds(),
|
|
122
|
+
in_progress: true,
|
|
123
|
+
};
|
|
124
|
+
turnState.stack.push(seg);
|
|
125
|
+
return seg;
|
|
126
|
+
}
|
|
127
|
+
function popSegment(turnState, expectedName) {
|
|
128
|
+
// Defensive: pop the topmost segment whose name matches (if
|
|
129
|
+
// provided). Out-of-order events would otherwise leave dangling
|
|
130
|
+
// segments. If no match, pop the topmost.
|
|
131
|
+
let idx = turnState.stack.length - 1;
|
|
132
|
+
if (expectedName) {
|
|
133
|
+
while (idx >= 0 && turnState.stack[idx].name !== expectedName)
|
|
134
|
+
idx--;
|
|
135
|
+
}
|
|
136
|
+
if (idx < 0)
|
|
137
|
+
return undefined;
|
|
138
|
+
const seg = turnState.stack.splice(idx, 1)[0];
|
|
139
|
+
seg.end_time = nowSeconds();
|
|
140
|
+
delete seg.in_progress;
|
|
141
|
+
return seg;
|
|
142
|
+
}
|
|
143
|
+
function closeSegment(turnState, expectedName, extra) {
|
|
144
|
+
const seg = popSegment(turnState, expectedName);
|
|
145
|
+
if (!seg)
|
|
146
|
+
return;
|
|
147
|
+
if (extra?.error)
|
|
148
|
+
seg.error = true;
|
|
149
|
+
if (extra?.annotations)
|
|
150
|
+
seg.annotations = { ...seg.annotations, ...extra.annotations };
|
|
151
|
+
if (extra?.metadata)
|
|
152
|
+
seg.metadata = { default: { ...(seg.metadata?.default ?? {}), ...extra.metadata } };
|
|
153
|
+
if (turnState.sampled) {
|
|
154
|
+
turnState.closed.push(seg);
|
|
155
|
+
// Once the root closes, the whole turn graduates to outbox.
|
|
156
|
+
if (turnState.stack.length === 0) {
|
|
157
|
+
outbox.push(...turnState.closed);
|
|
158
|
+
if (outbox.length >= maxBatchSegments) {
|
|
159
|
+
lastFlushPromise = lastFlushPromise.then(doFlush, doFlush);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
scheduleTimedFlush();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// ─── Event-to-segment dispatch ─────────────────────────────────────
|
|
168
|
+
function handleEvent(event) {
|
|
169
|
+
if (stopped)
|
|
170
|
+
return;
|
|
171
|
+
const runId = event.payload?.runId;
|
|
172
|
+
if (!runId)
|
|
173
|
+
return; // Events without a turn anchor — skip.
|
|
174
|
+
switch (event.type) {
|
|
175
|
+
case 'agentfootprint.agent.turn_start': {
|
|
176
|
+
const sampled = sampleRate >= 1 || Math.random() < sampleRate;
|
|
177
|
+
const turnState = {
|
|
178
|
+
traceId: makeTraceId(),
|
|
179
|
+
stack: [],
|
|
180
|
+
closed: [],
|
|
181
|
+
sampled,
|
|
182
|
+
};
|
|
183
|
+
activeTurns.set(runId, turnState);
|
|
184
|
+
if (sampled)
|
|
185
|
+
pushSegment(turnState, opts.serviceName);
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
case 'agentfootprint.agent.turn_end': {
|
|
189
|
+
const t = activeTurns.get(runId);
|
|
190
|
+
if (!t)
|
|
191
|
+
break;
|
|
192
|
+
// Close everything still on the stack — defensive against
|
|
193
|
+
// missing `_end` events (e.g., pause/resume mid-turn).
|
|
194
|
+
while (t.stack.length > 0)
|
|
195
|
+
closeSegment(t, undefined);
|
|
196
|
+
activeTurns.delete(runId);
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
case 'agentfootprint.agent.iteration_start': {
|
|
200
|
+
const t = activeTurns.get(runId);
|
|
201
|
+
if (t?.sampled)
|
|
202
|
+
pushSegment(t, `iteration:${event.payload.iteration ?? '?'}`);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
case 'agentfootprint.agent.iteration_end': {
|
|
206
|
+
const t = activeTurns.get(runId);
|
|
207
|
+
if (t?.sampled)
|
|
208
|
+
closeSegment(t, undefined);
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
case 'agentfootprint.stream.llm_start': {
|
|
212
|
+
const t = activeTurns.get(runId);
|
|
213
|
+
if (!t?.sampled)
|
|
214
|
+
break;
|
|
215
|
+
const seg = pushSegment(t, 'llm');
|
|
216
|
+
const model = event.payload.model;
|
|
217
|
+
if (model)
|
|
218
|
+
seg.annotations = { model };
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
case 'agentfootprint.stream.llm_end': {
|
|
222
|
+
const t = activeTurns.get(runId);
|
|
223
|
+
if (!t?.sampled)
|
|
224
|
+
break;
|
|
225
|
+
closeSegment(t, 'llm', {
|
|
226
|
+
metadata: { event: event.payload },
|
|
227
|
+
});
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
case 'agentfootprint.stream.tool_start': {
|
|
231
|
+
const t = activeTurns.get(runId);
|
|
232
|
+
if (!t?.sampled)
|
|
233
|
+
break;
|
|
234
|
+
const toolName = event.payload.toolName ?? 'tool';
|
|
235
|
+
const seg = pushSegment(t, `tool:${toolName}`);
|
|
236
|
+
seg.annotations = { toolName };
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
case 'agentfootprint.stream.tool_end': {
|
|
240
|
+
const t = activeTurns.get(runId);
|
|
241
|
+
if (!t?.sampled)
|
|
242
|
+
break;
|
|
243
|
+
const toolName = event.payload.toolName;
|
|
244
|
+
closeSegment(t, toolName ? `tool:${toolName}` : undefined, {
|
|
245
|
+
error: event.payload.error !== undefined,
|
|
246
|
+
});
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
// Other events become annotations on the topmost active segment
|
|
250
|
+
// (cheaper than spawning a subsegment per event).
|
|
251
|
+
default: {
|
|
252
|
+
const t = activeTurns.get(runId);
|
|
253
|
+
const top = t?.stack[t.stack.length - 1];
|
|
254
|
+
if (!t?.sampled || !top)
|
|
255
|
+
break;
|
|
256
|
+
// Annotate cost ticks specially so they're queryable in
|
|
257
|
+
// X-Ray Insights.
|
|
258
|
+
if (event.type === 'agentfootprint.cost.tick') {
|
|
259
|
+
const p = event.payload;
|
|
260
|
+
if (typeof p.cumulativeCostUsd === 'number') {
|
|
261
|
+
top.annotations = { ...top.annotations, cumulativeCostUsd: p.cumulativeCostUsd };
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
name: 'xray',
|
|
270
|
+
capabilities: { events: true, traces: true },
|
|
271
|
+
exportEvent: handleEvent,
|
|
272
|
+
async flush() {
|
|
273
|
+
// Force-close any in-flight turn segments so partial traces
|
|
274
|
+
// make it into X-Ray on shutdown.
|
|
275
|
+
for (const [, t] of activeTurns) {
|
|
276
|
+
if (!t.sampled)
|
|
277
|
+
continue;
|
|
278
|
+
while (t.stack.length > 0)
|
|
279
|
+
closeSegment(t, undefined);
|
|
280
|
+
}
|
|
281
|
+
while (outbox.length > 0) {
|
|
282
|
+
const before = lastFlushPromise;
|
|
283
|
+
await before;
|
|
284
|
+
if (outbox.length > 0) {
|
|
285
|
+
lastFlushPromise = doFlush();
|
|
286
|
+
}
|
|
287
|
+
if (lastFlushPromise === before && outbox.length === 0)
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
stop() {
|
|
292
|
+
stopped = true;
|
|
293
|
+
if (timer) {
|
|
294
|
+
clearTimeout(timer);
|
|
295
|
+
timer = undefined;
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
_onError(err, event) {
|
|
299
|
+
onErrorHook =
|
|
300
|
+
onErrorHook ??
|
|
301
|
+
((e) => {
|
|
302
|
+
// eslint-disable-next-line no-console
|
|
303
|
+
console.error(`[xrayObservability] flush failed:`, e.message);
|
|
304
|
+
});
|
|
305
|
+
onErrorHook(err, event);
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
exports.xrayObservability = xrayObservability;
|
|
310
|
+
// ─── ID + time helpers ───────────────────────────────────────────────
|
|
311
|
+
/**
|
|
312
|
+
* Generate an X-Ray trace ID. Format:
|
|
313
|
+
* `1-{8-hex-of-unix-timestamp}-{24-hex-random}`
|
|
314
|
+
* (Note X-Ray's docs say "12 hex" for the random part; the actual
|
|
315
|
+
* spec is 24 hex / 96-bit. AWS examples use 24.)
|
|
316
|
+
*/
|
|
317
|
+
function makeTraceId() {
|
|
318
|
+
const seconds = Math.floor(Date.now() / 1000);
|
|
319
|
+
return `1-${seconds.toString(16).padStart(8, '0')}-${hexId(24)}`;
|
|
320
|
+
}
|
|
321
|
+
/** Generate a hex string of `len` chars, cryptographically-strong
|
|
322
|
+
* where available, falling back to Math.random for environments
|
|
323
|
+
* without `crypto.getRandomValues` (older runtimes). */
|
|
324
|
+
function hexId(len) {
|
|
325
|
+
const bytes = Math.ceil(len / 2);
|
|
326
|
+
// Try the Web Crypto / Node Crypto API first.
|
|
327
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
328
|
+
const cryptoApi = globalThis.crypto;
|
|
329
|
+
if (cryptoApi?.getRandomValues) {
|
|
330
|
+
const buf = new Uint8Array(bytes);
|
|
331
|
+
cryptoApi.getRandomValues(buf);
|
|
332
|
+
return Array.from(buf, (b) => b.toString(16).padStart(2, '0'))
|
|
333
|
+
.join('')
|
|
334
|
+
.slice(0, len);
|
|
335
|
+
}
|
|
336
|
+
// Fallback (deterministic-quality, NOT for security-critical IDs —
|
|
337
|
+
// X-Ray IDs aren't security boundaries, just trace correlation).
|
|
338
|
+
let s = '';
|
|
339
|
+
while (s.length < len)
|
|
340
|
+
s += Math.random().toString(16).slice(2);
|
|
341
|
+
return s.slice(0, len);
|
|
342
|
+
}
|
|
343
|
+
/** X-Ray timestamps are unix seconds with fractional precision. */
|
|
344
|
+
function nowSeconds() {
|
|
345
|
+
return Date.now() / 1000;
|
|
346
|
+
}
|
|
347
|
+
// ─── SDK construction (lazy) ─────────────────────────────────────────
|
|
348
|
+
function createXRayClient(region) {
|
|
349
|
+
let mod;
|
|
350
|
+
try {
|
|
351
|
+
mod = (0, lazyRequire_js_1.lazyRequire)('@aws-sdk/client-xray');
|
|
352
|
+
}
|
|
353
|
+
catch {
|
|
354
|
+
throw new Error('xrayObservability requires the `@aws-sdk/client-xray` peer dependency.\n' +
|
|
355
|
+
' Install: npm install @aws-sdk/client-xray\n' +
|
|
356
|
+
' Or pass `_client` for test injection.');
|
|
357
|
+
}
|
|
358
|
+
if (!mod.XRayClient || !mod.PutTraceSegmentsCommand) {
|
|
359
|
+
throw new Error('xrayObservability: `@aws-sdk/client-xray` is installed but `XRayClient` / ' +
|
|
360
|
+
'`PutTraceSegmentsCommand` was not found. Update the SDK.');
|
|
361
|
+
}
|
|
362
|
+
const sdkClient = new mod.XRayClient({ ...(region && { region }) });
|
|
363
|
+
return {
|
|
364
|
+
async putTraceSegments(input) {
|
|
365
|
+
const cmd = new mod.PutTraceSegmentsCommand(input);
|
|
366
|
+
await sdkClient.send(cmd);
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
//# sourceMappingURL=xray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xray.js","sourceRoot":"","sources":["../../../src/adapters/observability/xray.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;;;AAGH,6DAAuD;AAyDvD,wEAAwE;AAExE,SAAgB,iBAAiB,CAAC,IAA8B;IAC9D,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACtB,MAAM,IAAI,SAAS,CACjB,mDAAmD;YAC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|
+
* agent.turn_start ↦ root segment (one trace per turn)
|
|
7
|
+
* agent.turn_end ↦ close root segment + flush
|
|
8
|
+
* agent.iteration_start ↦ push subsegment under root
|
|
9
|
+
* agent.iteration_end ↦ close iteration subsegment
|
|
10
|
+
* stream.llm_start ↦ push leaf subsegment (model call)
|
|
11
|
+
* stream.llm_end ↦ close llm subsegment
|
|
12
|
+
* stream.tool_start ↦ push leaf subsegment (tool call)
|
|
13
|
+
* stream.tool_end ↦ close tool subsegment
|
|
14
|
+
*
|
|
15
|
+
* The result in the X-Ray Trace Map: a hierarchical timeline of every
|
|
16
|
+
* agent run — turn → iteration → llm-call/tool-call — queryable in
|
|
17
|
+
* X-Ray Insights, joinable with the rest of your AWS distributed
|
|
18
|
+
* trace via `AWSTraceHeader` propagation (consumer's responsibility
|
|
19
|
+
* to wire upstream/downstream IDs).
|
|
20
|
+
*
|
|
21
|
+
* Subpath: `agentfootprint/observability-providers`
|
|
22
|
+
* Peer dep: `@aws-sdk/client-xray` (OPTIONAL — installed only when
|
|
23
|
+
* this adapter is used).
|
|
24
|
+
*
|
|
25
|
+
* Sampling:
|
|
26
|
+
* By default every turn produces one trace. Pass `sampleRate: 0.1`
|
|
27
|
+
* to sample 10% of turns — sampling decisions are made at
|
|
28
|
+
* `turn_start` and persist for the whole turn (so partial traces
|
|
29
|
+
* never reach X-Ray).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { xrayObservability } from 'agentfootprint/observability-providers';
|
|
34
|
+
* import { microtaskBatchDriver } from 'footprintjs/detach';
|
|
35
|
+
*
|
|
36
|
+
* agent.enable.observability({
|
|
37
|
+
* strategy: xrayObservability({
|
|
38
|
+
* region: 'us-east-1',
|
|
39
|
+
* serviceName: 'my-agent',
|
|
40
|
+
* sampleRate: 0.1, // 10% sampling
|
|
41
|
+
* }),
|
|
42
|
+
* detach: { driver: microtaskBatchDriver, mode: 'forget' },
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example Test injection
|
|
47
|
+
* ```ts
|
|
48
|
+
* xrayObservability({
|
|
49
|
+
* serviceName: 'test',
|
|
50
|
+
* _client: {
|
|
51
|
+
* putTraceSegments: async (input) => { capturedDocs.push(input); },
|
|
52
|
+
* },
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
import { lazyRequire } from '../../lib/lazyRequire.js';
|
|
57
|
+
// ─── Strategy factory ────────────────────────────────────────────────
|
|
58
|
+
export function xrayObservability(opts) {
|
|
59
|
+
if (!opts.serviceName) {
|
|
60
|
+
throw new TypeError(`[xrayObservability] \`serviceName\` is required. ` +
|
|
61
|
+
`Pass an identifier visible in your X-Ray service map, e.g. 'my-agent-prod'.`);
|
|
62
|
+
}
|
|
63
|
+
const sampleRate = opts.sampleRate ?? 1;
|
|
64
|
+
const maxBatchSegments = opts.maxBatchSegments ?? 25;
|
|
65
|
+
const flushIntervalMs = opts.flushIntervalMs ?? 1000;
|
|
66
|
+
// Per-turn state. agentfootprint events arrive interleaved across
|
|
67
|
+
// multiple in-flight turns; we key the active stack by `runId`
|
|
68
|
+
// (every event payload carries it after enrichment).
|
|
69
|
+
const activeTurns = new Map();
|
|
70
|
+
// Outbound segment buffer (flat list of closed segments ready for
|
|
71
|
+
// PutTraceSegments). Drained by flush() / size-trigger / time-trigger.
|
|
72
|
+
const outbox = [];
|
|
73
|
+
let lastFlushPromise = Promise.resolve();
|
|
74
|
+
let timer;
|
|
75
|
+
let stopped = false;
|
|
76
|
+
let onErrorHook;
|
|
77
|
+
// Lazy SDK client.
|
|
78
|
+
let client = opts._client;
|
|
79
|
+
function ensureClient() {
|
|
80
|
+
if (client)
|
|
81
|
+
return client;
|
|
82
|
+
client = createXRayClient(opts.region);
|
|
83
|
+
return client;
|
|
84
|
+
}
|
|
85
|
+
function scheduleTimedFlush() {
|
|
86
|
+
if (timer || flushIntervalMs <= 0 || stopped)
|
|
87
|
+
return;
|
|
88
|
+
timer = setTimeout(() => {
|
|
89
|
+
timer = undefined;
|
|
90
|
+
void doFlush();
|
|
91
|
+
}, flushIntervalMs);
|
|
92
|
+
}
|
|
93
|
+
async function doFlush() {
|
|
94
|
+
if (outbox.length === 0 || stopped)
|
|
95
|
+
return;
|
|
96
|
+
const batch = outbox.splice(0, maxBatchSegments);
|
|
97
|
+
try {
|
|
98
|
+
await ensureClient().putTraceSegments({
|
|
99
|
+
TraceSegmentDocuments: batch.map((s) => JSON.stringify(s)),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
onErrorHook?.(err instanceof Error ? err : new Error(String(err)));
|
|
104
|
+
}
|
|
105
|
+
// If outbox grew during the put (size > maxBatchSegments emits
|
|
106
|
+
// arrived), chain another flush.
|
|
107
|
+
if (outbox.length > 0 && !stopped) {
|
|
108
|
+
lastFlushPromise = lastFlushPromise.then(doFlush, doFlush);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function pushSegment(turnState, name) {
|
|
112
|
+
const parent = turnState.stack[turnState.stack.length - 1];
|
|
113
|
+
const seg = {
|
|
114
|
+
name,
|
|
115
|
+
id: hexId(16),
|
|
116
|
+
trace_id: turnState.traceId,
|
|
117
|
+
...(parent && { parent_id: parent.id }),
|
|
118
|
+
start_time: nowSeconds(),
|
|
119
|
+
in_progress: true,
|
|
120
|
+
};
|
|
121
|
+
turnState.stack.push(seg);
|
|
122
|
+
return seg;
|
|
123
|
+
}
|
|
124
|
+
function popSegment(turnState, expectedName) {
|
|
125
|
+
// Defensive: pop the topmost segment whose name matches (if
|
|
126
|
+
// provided). Out-of-order events would otherwise leave dangling
|
|
127
|
+
// segments. If no match, pop the topmost.
|
|
128
|
+
let idx = turnState.stack.length - 1;
|
|
129
|
+
if (expectedName) {
|
|
130
|
+
while (idx >= 0 && turnState.stack[idx].name !== expectedName)
|
|
131
|
+
idx--;
|
|
132
|
+
}
|
|
133
|
+
if (idx < 0)
|
|
134
|
+
return undefined;
|
|
135
|
+
const seg = turnState.stack.splice(idx, 1)[0];
|
|
136
|
+
seg.end_time = nowSeconds();
|
|
137
|
+
delete seg.in_progress;
|
|
138
|
+
return seg;
|
|
139
|
+
}
|
|
140
|
+
function closeSegment(turnState, expectedName, extra) {
|
|
141
|
+
const seg = popSegment(turnState, expectedName);
|
|
142
|
+
if (!seg)
|
|
143
|
+
return;
|
|
144
|
+
if (extra?.error)
|
|
145
|
+
seg.error = true;
|
|
146
|
+
if (extra?.annotations)
|
|
147
|
+
seg.annotations = { ...seg.annotations, ...extra.annotations };
|
|
148
|
+
if (extra?.metadata)
|
|
149
|
+
seg.metadata = { default: { ...(seg.metadata?.default ?? {}), ...extra.metadata } };
|
|
150
|
+
if (turnState.sampled) {
|
|
151
|
+
turnState.closed.push(seg);
|
|
152
|
+
// Once the root closes, the whole turn graduates to outbox.
|
|
153
|
+
if (turnState.stack.length === 0) {
|
|
154
|
+
outbox.push(...turnState.closed);
|
|
155
|
+
if (outbox.length >= maxBatchSegments) {
|
|
156
|
+
lastFlushPromise = lastFlushPromise.then(doFlush, doFlush);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
scheduleTimedFlush();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// ─── Event-to-segment dispatch ─────────────────────────────────────
|
|
165
|
+
function handleEvent(event) {
|
|
166
|
+
if (stopped)
|
|
167
|
+
return;
|
|
168
|
+
const runId = event.payload?.runId;
|
|
169
|
+
if (!runId)
|
|
170
|
+
return; // Events without a turn anchor — skip.
|
|
171
|
+
switch (event.type) {
|
|
172
|
+
case 'agentfootprint.agent.turn_start': {
|
|
173
|
+
const sampled = sampleRate >= 1 || Math.random() < sampleRate;
|
|
174
|
+
const turnState = {
|
|
175
|
+
traceId: makeTraceId(),
|
|
176
|
+
stack: [],
|
|
177
|
+
closed: [],
|
|
178
|
+
sampled,
|
|
179
|
+
};
|
|
180
|
+
activeTurns.set(runId, turnState);
|
|
181
|
+
if (sampled)
|
|
182
|
+
pushSegment(turnState, opts.serviceName);
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
case 'agentfootprint.agent.turn_end': {
|
|
186
|
+
const t = activeTurns.get(runId);
|
|
187
|
+
if (!t)
|
|
188
|
+
break;
|
|
189
|
+
// Close everything still on the stack — defensive against
|
|
190
|
+
// missing `_end` events (e.g., pause/resume mid-turn).
|
|
191
|
+
while (t.stack.length > 0)
|
|
192
|
+
closeSegment(t, undefined);
|
|
193
|
+
activeTurns.delete(runId);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
case 'agentfootprint.agent.iteration_start': {
|
|
197
|
+
const t = activeTurns.get(runId);
|
|
198
|
+
if (t?.sampled)
|
|
199
|
+
pushSegment(t, `iteration:${event.payload.iteration ?? '?'}`);
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
case 'agentfootprint.agent.iteration_end': {
|
|
203
|
+
const t = activeTurns.get(runId);
|
|
204
|
+
if (t?.sampled)
|
|
205
|
+
closeSegment(t, undefined);
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
case 'agentfootprint.stream.llm_start': {
|
|
209
|
+
const t = activeTurns.get(runId);
|
|
210
|
+
if (!t?.sampled)
|
|
211
|
+
break;
|
|
212
|
+
const seg = pushSegment(t, 'llm');
|
|
213
|
+
const model = event.payload.model;
|
|
214
|
+
if (model)
|
|
215
|
+
seg.annotations = { model };
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
case 'agentfootprint.stream.llm_end': {
|
|
219
|
+
const t = activeTurns.get(runId);
|
|
220
|
+
if (!t?.sampled)
|
|
221
|
+
break;
|
|
222
|
+
closeSegment(t, 'llm', {
|
|
223
|
+
metadata: { event: event.payload },
|
|
224
|
+
});
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
case 'agentfootprint.stream.tool_start': {
|
|
228
|
+
const t = activeTurns.get(runId);
|
|
229
|
+
if (!t?.sampled)
|
|
230
|
+
break;
|
|
231
|
+
const toolName = event.payload.toolName ?? 'tool';
|
|
232
|
+
const seg = pushSegment(t, `tool:${toolName}`);
|
|
233
|
+
seg.annotations = { toolName };
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
case 'agentfootprint.stream.tool_end': {
|
|
237
|
+
const t = activeTurns.get(runId);
|
|
238
|
+
if (!t?.sampled)
|
|
239
|
+
break;
|
|
240
|
+
const toolName = event.payload.toolName;
|
|
241
|
+
closeSegment(t, toolName ? `tool:${toolName}` : undefined, {
|
|
242
|
+
error: event.payload.error !== undefined,
|
|
243
|
+
});
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
// Other events become annotations on the topmost active segment
|
|
247
|
+
// (cheaper than spawning a subsegment per event).
|
|
248
|
+
default: {
|
|
249
|
+
const t = activeTurns.get(runId);
|
|
250
|
+
const top = t?.stack[t.stack.length - 1];
|
|
251
|
+
if (!t?.sampled || !top)
|
|
252
|
+
break;
|
|
253
|
+
// Annotate cost ticks specially so they're queryable in
|
|
254
|
+
// X-Ray Insights.
|
|
255
|
+
if (event.type === 'agentfootprint.cost.tick') {
|
|
256
|
+
const p = event.payload;
|
|
257
|
+
if (typeof p.cumulativeCostUsd === 'number') {
|
|
258
|
+
top.annotations = { ...top.annotations, cumulativeCostUsd: p.cumulativeCostUsd };
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
name: 'xray',
|
|
267
|
+
capabilities: { events: true, traces: true },
|
|
268
|
+
exportEvent: handleEvent,
|
|
269
|
+
async flush() {
|
|
270
|
+
// Force-close any in-flight turn segments so partial traces
|
|
271
|
+
// make it into X-Ray on shutdown.
|
|
272
|
+
for (const [, t] of activeTurns) {
|
|
273
|
+
if (!t.sampled)
|
|
274
|
+
continue;
|
|
275
|
+
while (t.stack.length > 0)
|
|
276
|
+
closeSegment(t, undefined);
|
|
277
|
+
}
|
|
278
|
+
while (outbox.length > 0) {
|
|
279
|
+
const before = lastFlushPromise;
|
|
280
|
+
await before;
|
|
281
|
+
if (outbox.length > 0) {
|
|
282
|
+
lastFlushPromise = doFlush();
|
|
283
|
+
}
|
|
284
|
+
if (lastFlushPromise === before && outbox.length === 0)
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
stop() {
|
|
289
|
+
stopped = true;
|
|
290
|
+
if (timer) {
|
|
291
|
+
clearTimeout(timer);
|
|
292
|
+
timer = undefined;
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
_onError(err, event) {
|
|
296
|
+
onErrorHook =
|
|
297
|
+
onErrorHook ??
|
|
298
|
+
((e) => {
|
|
299
|
+
// eslint-disable-next-line no-console
|
|
300
|
+
console.error(`[xrayObservability] flush failed:`, e.message);
|
|
301
|
+
});
|
|
302
|
+
onErrorHook(err, event);
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
// ─── ID + time helpers ───────────────────────────────────────────────
|
|
307
|
+
/**
|
|
308
|
+
* Generate an X-Ray trace ID. Format:
|
|
309
|
+
* `1-{8-hex-of-unix-timestamp}-{24-hex-random}`
|
|
310
|
+
* (Note X-Ray's docs say "12 hex" for the random part; the actual
|
|
311
|
+
* spec is 24 hex / 96-bit. AWS examples use 24.)
|
|
312
|
+
*/
|
|
313
|
+
function makeTraceId() {
|
|
314
|
+
const seconds = Math.floor(Date.now() / 1000);
|
|
315
|
+
return `1-${seconds.toString(16).padStart(8, '0')}-${hexId(24)}`;
|
|
316
|
+
}
|
|
317
|
+
/** Generate a hex string of `len` chars, cryptographically-strong
|
|
318
|
+
* where available, falling back to Math.random for environments
|
|
319
|
+
* without `crypto.getRandomValues` (older runtimes). */
|
|
320
|
+
function hexId(len) {
|
|
321
|
+
const bytes = Math.ceil(len / 2);
|
|
322
|
+
// Try the Web Crypto / Node Crypto API first.
|
|
323
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
324
|
+
const cryptoApi = globalThis.crypto;
|
|
325
|
+
if (cryptoApi?.getRandomValues) {
|
|
326
|
+
const buf = new Uint8Array(bytes);
|
|
327
|
+
cryptoApi.getRandomValues(buf);
|
|
328
|
+
return Array.from(buf, (b) => b.toString(16).padStart(2, '0'))
|
|
329
|
+
.join('')
|
|
330
|
+
.slice(0, len);
|
|
331
|
+
}
|
|
332
|
+
// Fallback (deterministic-quality, NOT for security-critical IDs —
|
|
333
|
+
// X-Ray IDs aren't security boundaries, just trace correlation).
|
|
334
|
+
let s = '';
|
|
335
|
+
while (s.length < len)
|
|
336
|
+
s += Math.random().toString(16).slice(2);
|
|
337
|
+
return s.slice(0, len);
|
|
338
|
+
}
|
|
339
|
+
/** X-Ray timestamps are unix seconds with fractional precision. */
|
|
340
|
+
function nowSeconds() {
|
|
341
|
+
return Date.now() / 1000;
|
|
342
|
+
}
|
|
343
|
+
// ─── SDK construction (lazy) ─────────────────────────────────────────
|
|
344
|
+
function createXRayClient(region) {
|
|
345
|
+
let mod;
|
|
346
|
+
try {
|
|
347
|
+
mod = lazyRequire('@aws-sdk/client-xray');
|
|
348
|
+
}
|
|
349
|
+
catch {
|
|
350
|
+
throw new Error('xrayObservability requires the `@aws-sdk/client-xray` peer dependency.\n' +
|
|
351
|
+
' Install: npm install @aws-sdk/client-xray\n' +
|
|
352
|
+
' Or pass `_client` for test injection.');
|
|
353
|
+
}
|
|
354
|
+
if (!mod.XRayClient || !mod.PutTraceSegmentsCommand) {
|
|
355
|
+
throw new Error('xrayObservability: `@aws-sdk/client-xray` is installed but `XRayClient` / ' +
|
|
356
|
+
'`PutTraceSegmentsCommand` was not found. Update the SDK.');
|
|
357
|
+
}
|
|
358
|
+
const sdkClient = new mod.XRayClient({ ...(region && { region }) });
|
|
359
|
+
return {
|
|
360
|
+
async putTraceSegments(input) {
|
|
361
|
+
const cmd = new mod.PutTraceSegmentsCommand(input);
|
|
362
|
+
await sdkClient.send(cmd);
|
|
363
|
+
},
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
//# sourceMappingURL=xray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xray.js","sourceRoot":"","sources":["../../../../src/adapters/observability/xray.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAyDvD,wEAAwE;AAExE,MAAM,UAAU,iBAAiB,CAAC,IAA8B;IAC9D,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACtB,MAAM,IAAI,SAAS,CACjB,mDAAmD;YACjD,6EAA6E,CAChF,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC;IACxC,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,IAAI,EAAE,CAAC;IACrD,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC;IAErD,kEAAkE;IAClE,+DAA+D;IAC/D,qDAAqD;IACrD,MAAM,WAAW,GAAG,IAAI,GAAG,EAQxB,CAAC;IAEJ,kEAAkE;IAClE,uEAAuE;IACvE,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,IAAI,gBAAgB,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IACxD,IAAI,KAAgD,CAAC;IACrD,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,WAA4E,CAAC;IAEjF,mBAAmB;IACnB,IAAI,MAAM,GAA+B,IAAI,CAAC,OAAO,CAAC;IACtD,SAAS,YAAY;QACnB,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAC1B,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,SA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AC,MAAM,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAEjE,CAAC;IACF,OAAO;QACL,KAAK,CAAC,gBAAgB,CAAC,KAAK;YAC1B,MAAM,GAAG,GAAG,IAAK,GAAG,CAAC,uBAAuD,CAAC,KAAK,CAAC,CAAC;YACpF,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -28,11 +28,12 @@
|
|
|
28
28
|
*
|
|
29
29
|
* Roadmap:
|
|
30
30
|
* - agentcoreObservability ← v2.8.1
|
|
31
|
-
* - cloudwatchObservability ← v2.8.2
|
|
32
|
-
* - xrayObservability ← v2.8.3
|
|
31
|
+
* - cloudwatchObservability ← v2.8.2
|
|
32
|
+
* - xrayObservability ← v2.8.3 (this release)
|
|
33
33
|
* - otelObservability ← v2.9.x
|
|
34
34
|
* - datadogObservability ← v2.9.x
|
|
35
35
|
*/
|
|
36
36
|
export { agentcoreObservability, } from './adapters/observability/agentcore.js';
|
|
37
37
|
export { cloudwatchObservability, } from './adapters/observability/cloudwatch.js';
|
|
38
|
+
export { xrayObservability, } from './adapters/observability/xray.js';
|
|
38
39
|
//# sourceMappingURL=observability-providers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observability-providers.js","sourceRoot":"","sources":["../../src/observability-providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EACL,sBAAsB,GAEvB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,uBAAuB,GAExB,MAAM,wCAAwC,CAAC"}
|
|
1
|
+
{"version":3,"file":"observability-providers.js","sourceRoot":"","sources":["../../src/observability-providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EACL,sBAAsB,GAEvB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,uBAAuB,GAExB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,iBAAiB,GAGlB,MAAM,kCAAkC,CAAC"}
|
|
@@ -29,15 +29,17 @@
|
|
|
29
29
|
*
|
|
30
30
|
* Roadmap:
|
|
31
31
|
* - agentcoreObservability ← v2.8.1
|
|
32
|
-
* - cloudwatchObservability ← v2.8.2
|
|
33
|
-
* - xrayObservability ← v2.8.3
|
|
32
|
+
* - cloudwatchObservability ← v2.8.2
|
|
33
|
+
* - xrayObservability ← v2.8.3 (this release)
|
|
34
34
|
* - otelObservability ← v2.9.x
|
|
35
35
|
* - datadogObservability ← v2.9.x
|
|
36
36
|
*/
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.cloudwatchObservability = exports.agentcoreObservability = void 0;
|
|
38
|
+
exports.xrayObservability = exports.cloudwatchObservability = exports.agentcoreObservability = void 0;
|
|
39
39
|
var agentcore_js_1 = require("./adapters/observability/agentcore.js");
|
|
40
40
|
Object.defineProperty(exports, "agentcoreObservability", { enumerable: true, get: function () { return agentcore_js_1.agentcoreObservability; } });
|
|
41
41
|
var cloudwatch_js_1 = require("./adapters/observability/cloudwatch.js");
|
|
42
42
|
Object.defineProperty(exports, "cloudwatchObservability", { enumerable: true, get: function () { return cloudwatch_js_1.cloudwatchObservability; } });
|
|
43
|
+
var xray_js_1 = require("./adapters/observability/xray.js");
|
|
44
|
+
Object.defineProperty(exports, "xrayObservability", { enumerable: true, get: function () { return xray_js_1.xrayObservability; } });
|
|
43
45
|
//# sourceMappingURL=observability-providers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observability-providers.js","sourceRoot":"","sources":["../src/observability-providers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;AAEH,sEAG+C;AAF7C,sHAAA,sBAAsB,OAAA;AAGxB,wEAGgD;AAF9C,wHAAA,uBAAuB,OAAA"}
|
|
1
|
+
{"version":3,"file":"observability-providers.js","sourceRoot":"","sources":["../src/observability-providers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;AAEH,sEAG+C;AAF7C,sHAAA,sBAAsB,OAAA;AAGxB,wEAGgD;AAF9C,wHAAA,uBAAuB,OAAA;AAGzB,4DAI0C;AAHxC,4GAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xrayObservability — AWS X-Ray distributed-tracing adapter.
|
|
3
|
+
*
|
|
4
|
+
* Maps agentfootprint's event taxonomy onto AWS X-Ray segment trees:
|
|
5
|
+
*
|
|
6
|
+
* agent.turn_start ↦ root segment (one trace per turn)
|
|
7
|
+
* agent.turn_end ↦ close root segment + flush
|
|
8
|
+
* agent.iteration_start ↦ push subsegment under root
|
|
9
|
+
* agent.iteration_end ↦ close iteration subsegment
|
|
10
|
+
* stream.llm_start ↦ push leaf subsegment (model call)
|
|
11
|
+
* stream.llm_end ↦ close llm subsegment
|
|
12
|
+
* stream.tool_start ↦ push leaf subsegment (tool call)
|
|
13
|
+
* stream.tool_end ↦ close tool subsegment
|
|
14
|
+
*
|
|
15
|
+
* The result in the X-Ray Trace Map: a hierarchical timeline of every
|
|
16
|
+
* agent run — turn → iteration → llm-call/tool-call — queryable in
|
|
17
|
+
* X-Ray Insights, joinable with the rest of your AWS distributed
|
|
18
|
+
* trace via `AWSTraceHeader` propagation (consumer's responsibility
|
|
19
|
+
* to wire upstream/downstream IDs).
|
|
20
|
+
*
|
|
21
|
+
* Subpath: `agentfootprint/observability-providers`
|
|
22
|
+
* Peer dep: `@aws-sdk/client-xray` (OPTIONAL — installed only when
|
|
23
|
+
* this adapter is used).
|
|
24
|
+
*
|
|
25
|
+
* Sampling:
|
|
26
|
+
* By default every turn produces one trace. Pass `sampleRate: 0.1`
|
|
27
|
+
* to sample 10% of turns — sampling decisions are made at
|
|
28
|
+
* `turn_start` and persist for the whole turn (so partial traces
|
|
29
|
+
* never reach X-Ray).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { xrayObservability } from 'agentfootprint/observability-providers';
|
|
34
|
+
* import { microtaskBatchDriver } from 'footprintjs/detach';
|
|
35
|
+
*
|
|
36
|
+
* agent.enable.observability({
|
|
37
|
+
* strategy: xrayObservability({
|
|
38
|
+
* region: 'us-east-1',
|
|
39
|
+
* serviceName: 'my-agent',
|
|
40
|
+
* sampleRate: 0.1, // 10% sampling
|
|
41
|
+
* }),
|
|
42
|
+
* detach: { driver: microtaskBatchDriver, mode: 'forget' },
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example Test injection
|
|
47
|
+
* ```ts
|
|
48
|
+
* xrayObservability({
|
|
49
|
+
* serviceName: 'test',
|
|
50
|
+
* _client: {
|
|
51
|
+
* putTraceSegments: async (input) => { capturedDocs.push(input); },
|
|
52
|
+
* },
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
import type { ObservabilityStrategy } from '../../strategies/types.js';
|
|
57
|
+
export interface XrayObservabilityOptions {
|
|
58
|
+
/** AWS region. Falls back to AWS_REGION / AWS_DEFAULT_REGION env. */
|
|
59
|
+
readonly region?: string;
|
|
60
|
+
/** Service name on every emitted segment. Surfaces in X-Ray's
|
|
61
|
+
* service map. Required. */
|
|
62
|
+
readonly serviceName: string;
|
|
63
|
+
/** 0..1 — fraction of turns to sample. Default `1.0` (every turn).
|
|
64
|
+
* Decisions are made at `turn_start` and persist for the whole
|
|
65
|
+
* turn so partial traces never reach X-Ray. */
|
|
66
|
+
readonly sampleRate?: number;
|
|
67
|
+
/** Max segments buffered before forced flush. X-Ray's
|
|
68
|
+
* `PutTraceSegments` API accepts up to 50 segments per call;
|
|
69
|
+
* default 25 keeps latency tight. */
|
|
70
|
+
readonly maxBatchSegments?: number;
|
|
71
|
+
/** Forced flush window for low-traffic agents. Default 1000ms.
|
|
72
|
+
* `0` disables time-based flush. */
|
|
73
|
+
readonly flushIntervalMs?: number;
|
|
74
|
+
/** Test injection — bypasses SDK lazy-require entirely. */
|
|
75
|
+
readonly _client?: XRayLikeClient;
|
|
76
|
+
}
|
|
77
|
+
export interface XRayLikeClient {
|
|
78
|
+
putTraceSegments(input: {
|
|
79
|
+
TraceSegmentDocuments: ReadonlyArray<string>;
|
|
80
|
+
}): Promise<unknown>;
|
|
81
|
+
}
|
|
82
|
+
export declare function xrayObservability(opts: XrayObservabilityOptions): ObservabilityStrategy;
|
|
83
|
+
//# sourceMappingURL=xray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xray.d.ts","sourceRoot":"","sources":["../../../../src/adapters/observability/xray.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAIvE,MAAM,WAAW,wBAAwB;IACvC,qEAAqE;IACrE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;iCAC6B;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;oDAEgD;IAChD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;0CAEsC;IACtC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC;yCACqC;IACrC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;CACnC;AAID,MAAM,WAAW,cAAc;IAC7B,gBAAgB,CAAC,KAAK,EAAE;QAAE,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7F;AA6BD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,wBAAwB,GAAG,qBAAqB,CAuQvF"}
|
|
@@ -28,11 +28,12 @@
|
|
|
28
28
|
*
|
|
29
29
|
* Roadmap:
|
|
30
30
|
* - agentcoreObservability ← v2.8.1
|
|
31
|
-
* - cloudwatchObservability ← v2.8.2
|
|
32
|
-
* - xrayObservability ← v2.8.3
|
|
31
|
+
* - cloudwatchObservability ← v2.8.2
|
|
32
|
+
* - xrayObservability ← v2.8.3 (this release)
|
|
33
33
|
* - otelObservability ← v2.9.x
|
|
34
34
|
* - datadogObservability ← v2.9.x
|
|
35
35
|
*/
|
|
36
36
|
export { agentcoreObservability, type AgentcoreObservabilityOptions, } from './adapters/observability/agentcore.js';
|
|
37
37
|
export { cloudwatchObservability, type CloudwatchObservabilityOptions, } from './adapters/observability/cloudwatch.js';
|
|
38
|
+
export { xrayObservability, type XrayObservabilityOptions, type XRayLikeClient, } from './adapters/observability/xray.js';
|
|
38
39
|
//# sourceMappingURL=observability-providers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observability-providers.d.ts","sourceRoot":"","sources":["../../src/observability-providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EACL,sBAAsB,EACtB,KAAK,6BAA6B,GACnC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,KAAK,8BAA8B,GACpC,MAAM,wCAAwC,CAAC"}
|
|
1
|
+
{"version":3,"file":"observability-providers.d.ts","sourceRoot":"","sources":["../../src/observability-providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EACL,sBAAsB,EACtB,KAAK,6BAA6B,GACnC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,KAAK,8BAA8B,GACpC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,GACpB,MAAM,kCAAkC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentfootprint",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.3",
|
|
4
4
|
"description": "The explainable agent framework — build AI agents you can explain, audit, and trust. Built on footprintjs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sanjay Krishna Anbalagan",
|
|
@@ -171,6 +171,7 @@
|
|
|
171
171
|
"@aws-sdk/client-bedrock-agent-runtime": "*",
|
|
172
172
|
"@aws-sdk/client-bedrock-runtime": "*",
|
|
173
173
|
"@aws-sdk/client-cloudwatch-logs": "*",
|
|
174
|
+
"@aws-sdk/client-xray": "*",
|
|
174
175
|
"@modelcontextprotocol/sdk": "*",
|
|
175
176
|
"footprintjs": ">=4.17.1",
|
|
176
177
|
"ioredis": "*",
|
|
@@ -193,6 +194,9 @@
|
|
|
193
194
|
"@aws-sdk/client-cloudwatch-logs": {
|
|
194
195
|
"optional": true
|
|
195
196
|
},
|
|
197
|
+
"@aws-sdk/client-xray": {
|
|
198
|
+
"optional": true
|
|
199
|
+
},
|
|
196
200
|
"@modelcontextprotocol/sdk": {
|
|
197
201
|
"optional": true
|
|
198
202
|
},
|