@uselemma/tracing 3.0.1 → 3.0.2
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/span-helpers.d.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function trace<Input = unknown, Output = unknown>(name: string, fn: (input: Input) => Output | Promise<Output>): (input: Input) => Promise<Output>;
|
|
19
19
|
/**
|
|
20
|
-
* Wraps a tool function with a child span
|
|
20
|
+
* Wraps a tool function with a child span. Sets `span.type = "tool"`.
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* const lookupOrder = tool("lookup-order", async (orderId: string) => {
|
|
@@ -26,7 +26,7 @@ export declare function trace<Input = unknown, Output = unknown>(name: string, f
|
|
|
26
26
|
*/
|
|
27
27
|
export declare function tool<Input = unknown, Output = unknown>(name: string, fn: (input: Input) => Output | Promise<Output>): (input: Input) => Promise<Output>;
|
|
28
28
|
/**
|
|
29
|
-
* Wraps an LLM call with a child span
|
|
29
|
+
* Wraps an LLM call with a child span. Sets `span.type = "generation"`.
|
|
30
30
|
*
|
|
31
31
|
* Prefer provider instrumentation (OpenInference) for automatic LLM spans
|
|
32
32
|
* with prompt/completion/token attributes. Use this helper for custom or
|
|
@@ -39,7 +39,7 @@ export declare function tool<Input = unknown, Output = unknown>(name: string, fn
|
|
|
39
39
|
*/
|
|
40
40
|
export declare function llm<Input = unknown, Output = unknown>(name: string, fn: (input: Input) => Output | Promise<Output>): (input: Input) => Promise<Output>;
|
|
41
41
|
/**
|
|
42
|
-
* Wraps a retrieval function with a child span
|
|
42
|
+
* Wraps a retrieval function with a child span. Sets `span.type = "retriever"`.
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
45
|
* const search = retrieval("vector-search", async (query: string) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"span-helpers.d.ts","sourceRoot":"","sources":["../src/span-helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"span-helpers.d.ts","sourceRoot":"","sources":["../src/span-helpers.ts"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EACrD,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAC7C,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,CAAC,CAEnC;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EACpD,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAC7C,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,CAAC,CAEnC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,GAAG,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EACnD,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAC7C,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,CAAC,CAEnC;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EACzD,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAC7C,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,CAAC,CAEnC"}
|
package/dist/span-helpers.js
CHANGED
|
@@ -14,10 +14,13 @@ const api_1 = require("@opentelemetry/api");
|
|
|
14
14
|
* The span ends when the function returns (or throws). Return values are
|
|
15
15
|
* passed through unchanged.
|
|
16
16
|
*/
|
|
17
|
-
function spanHelper(spanName, fn) {
|
|
17
|
+
function spanHelper(spanName, fn, spanType) {
|
|
18
18
|
return async function (input) {
|
|
19
19
|
const tracer = api_1.trace.getTracer("lemma");
|
|
20
20
|
return tracer.startActiveSpan(spanName, async (span) => {
|
|
21
|
+
if (spanType) {
|
|
22
|
+
span.setAttribute("span.type", spanType);
|
|
23
|
+
}
|
|
21
24
|
try {
|
|
22
25
|
const result = await fn(input);
|
|
23
26
|
span.end();
|
|
@@ -53,7 +56,7 @@ function trace(name, fn) {
|
|
|
53
56
|
return spanHelper(name, fn);
|
|
54
57
|
}
|
|
55
58
|
/**
|
|
56
|
-
* Wraps a tool function with a child span
|
|
59
|
+
* Wraps a tool function with a child span. Sets `span.type = "tool"`.
|
|
57
60
|
*
|
|
58
61
|
* @example
|
|
59
62
|
* const lookupOrder = tool("lookup-order", async (orderId: string) => {
|
|
@@ -61,10 +64,10 @@ function trace(name, fn) {
|
|
|
61
64
|
* });
|
|
62
65
|
*/
|
|
63
66
|
function tool(name, fn) {
|
|
64
|
-
return spanHelper(
|
|
67
|
+
return spanHelper(name, fn, "tool");
|
|
65
68
|
}
|
|
66
69
|
/**
|
|
67
|
-
* Wraps an LLM call with a child span
|
|
70
|
+
* Wraps an LLM call with a child span. Sets `span.type = "generation"`.
|
|
68
71
|
*
|
|
69
72
|
* Prefer provider instrumentation (OpenInference) for automatic LLM spans
|
|
70
73
|
* with prompt/completion/token attributes. Use this helper for custom or
|
|
@@ -76,10 +79,10 @@ function tool(name, fn) {
|
|
|
76
79
|
* });
|
|
77
80
|
*/
|
|
78
81
|
function llm(name, fn) {
|
|
79
|
-
return spanHelper(
|
|
82
|
+
return spanHelper(name, fn, "generation");
|
|
80
83
|
}
|
|
81
84
|
/**
|
|
82
|
-
* Wraps a retrieval function with a child span
|
|
85
|
+
* Wraps a retrieval function with a child span. Sets `span.type = "retriever"`.
|
|
83
86
|
*
|
|
84
87
|
* @example
|
|
85
88
|
* const search = retrieval("vector-search", async (query: string) => {
|
|
@@ -87,6 +90,6 @@ function llm(name, fn) {
|
|
|
87
90
|
* });
|
|
88
91
|
*/
|
|
89
92
|
function retrieval(name, fn) {
|
|
90
|
-
return spanHelper(
|
|
93
|
+
return spanHelper(name, fn, "retriever");
|
|
91
94
|
}
|
|
92
95
|
//# sourceMappingURL=span-helpers.js.map
|
package/dist/span-helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"span-helpers.js","sourceRoot":"","sources":["../src/span-helpers.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"span-helpers.js","sourceRoot":"","sources":["../src/span-helpers.ts"],"names":[],"mappings":";;AAsDA,sBAKC;AAUD,oBAKC;AAcD,kBAKC;AAUD,8BAKC;AA5GD,4CAAwD;AAGxD;;;;;;;;GAQG;AACH,SAAS,UAAU,CACjB,QAAgB,EAChB,EAA8C,EAC9C,QAAiB;IAEjB,OAAO,KAAK,WAAW,KAAY;QACjC,MAAM,MAAM,GAAG,WAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC5C,OAAO,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAU,EAAE,EAAE;YAC3D,IAAI,QAAQ,EAAE,CAAC;gBACb,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;YAC3C,CAAC;YACD,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;gBAC/B,IAAI,CAAC,GAAG,EAAE,CAAC;gBACX,OAAO,MAAM,CAAC;YAChB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,eAAe,CAAC,GAAY,CAAC,CAAC;gBACnC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAA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