@uselemma/tracing 2.16.0 → 2.17.0
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/trace-wrapper.d.ts
CHANGED
|
@@ -6,9 +6,8 @@ export type TraceContext = {
|
|
|
6
6
|
runId: string;
|
|
7
7
|
/**
|
|
8
8
|
* Record the run output and end the agent span. Sets `ai.agent.output` on
|
|
9
|
-
* the span and calls `span.end()`
|
|
10
|
-
*
|
|
11
|
-
* return value is captured when the wrapped function completes.
|
|
9
|
+
* the span and calls `span.end()` — the parent span does not end until you
|
|
10
|
+
* call this (except on uncaught errors, which still end the span).
|
|
12
11
|
*/
|
|
13
12
|
onComplete: (result: unknown) => void;
|
|
14
13
|
/** Record an error on the span. Marks the span as errored. */
|
|
@@ -32,10 +31,8 @@ export type WrapRunOptions = {
|
|
|
32
31
|
* agent metadata (name, run ID, experiment flag), and handles error recording.
|
|
33
32
|
*
|
|
34
33
|
* `ai.agent.input` and `ai.agent.output` are set as JSON strings for Lemma
|
|
35
|
-
* ingestion and UI.
|
|
36
|
-
*
|
|
37
|
-
* to return. If you never call `onComplete`, the span ends when the wrapped
|
|
38
|
-
* function returns or throws, and the return value is used as output.
|
|
34
|
+
* ingestion and UI. You must call {@link TraceContext.onComplete} to set
|
|
35
|
+
* output and end the span. Uncaught errors still end the span with an error status.
|
|
39
36
|
*
|
|
40
37
|
* @example
|
|
41
38
|
* const myAgent = wrapAgent<{ topic: string }>(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace-wrapper.d.ts","sourceRoot":"","sources":["../src/trace-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAKxE,MAAM,MAAM,YAAY,GAAG;IACzB,wDAAwD;IACxD,IAAI,EAAE,IAAI,CAAC;IACX,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd
|
|
1
|
+
{"version":3,"file":"trace-wrapper.d.ts","sourceRoot":"","sources":["../src/trace-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAKxE,MAAM,MAAM,YAAY,GAAG;IACzB,wDAAwD;IACxD,IAAI,EAAE,IAAI,CAAC;IACX,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,UAAU,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,8DAA8D;IAC9D,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,+CAA+C;IAC/C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAkBF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,SAAS,CAAC,KAAK,GAAG,OAAO,EACvC,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,KAAK,GAAG,EACrD,OAAO,CAAC,EAAE,gBAAgB,UAGlB,GAAG,SACF,KAAK,eACC,cAAc;;;;GA+D9B"}
|
package/dist/trace-wrapper.js
CHANGED
|
@@ -26,10 +26,8 @@ function normalizeThreadId(threadId) {
|
|
|
26
26
|
* agent metadata (name, run ID, experiment flag), and handles error recording.
|
|
27
27
|
*
|
|
28
28
|
* `ai.agent.input` and `ai.agent.output` are set as JSON strings for Lemma
|
|
29
|
-
* ingestion and UI.
|
|
30
|
-
*
|
|
31
|
-
* to return. If you never call `onComplete`, the span ends when the wrapped
|
|
32
|
-
* function returns or throws, and the return value is used as output.
|
|
29
|
+
* ingestion and UI. You must call {@link TraceContext.onComplete} to set
|
|
30
|
+
* output and end the span. Uncaught errors still end the span with an error status.
|
|
33
31
|
*
|
|
34
32
|
* @example
|
|
35
33
|
* const myAgent = wrapAgent<{ topic: string }>(
|
|
@@ -83,11 +81,6 @@ function wrapAgent(agentName, fn, options) {
|
|
|
83
81
|
span.setStatus({ code: 2 }); // SpanStatusCode.ERROR
|
|
84
82
|
};
|
|
85
83
|
const result = await fn.call(this, { span, runId, onComplete, recordError }, input);
|
|
86
|
-
if (!outputSet) {
|
|
87
|
-
span.setAttribute("ai.agent.output", JSON.stringify(result) ?? "null");
|
|
88
|
-
span.end();
|
|
89
|
-
(0, debug_mode_1.lemmaDebug)("trace-wrapper", "span ended after fn returned (no onComplete)", { runId });
|
|
90
|
-
}
|
|
91
84
|
return { result, runId, span };
|
|
92
85
|
});
|
|
93
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace-wrapper.js","sourceRoot":"","sources":["../src/trace-wrapper.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"trace-wrapper.js","sourceRoot":"","sources":["../src/trace-wrapper.ts"],"names":[],"mappings":";;AA2EA,8BAuEC;AAlJD,4CAAwE;AACxE,+BAAoC;AACpC,6CAA0C;AAC1C,uDAA4D;AA6B5D,SAAS,mBAAmB,CAC1B,aAAsB,EACtB,cAAiC,EACjC,UAA2B;IAE3B,IAAI,aAAa;QAAE,OAAO,IAAI,CAAC;IAC/B,IAAI,OAAO,UAAU,EAAE,YAAY,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC,YAAY,CAAC;IAClF,OAAO,cAAc,EAAE,YAAY,KAAK,IAAI,CAAC;AAC/C,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAiB;IAC1C,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACnD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;IAChC,OAAO,OAAO,CAAC,MAAM,G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