@uselemma/tracing 0.6.0 → 0.8.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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/memory-exporter.d.ts.map +1 -1
- package/dist/memory-exporter.js +8 -0
- package/dist/memory-exporter.js.map +1 -1
- package/dist/trace-wrapper.d.ts +5 -0
- package/dist/trace-wrapper.d.ts.map +1 -0
- package/dist/trace-wrapper.js +29 -0
- package/dist/trace-wrapper.js.map +1 -0
- package/package.json +11 -9
- package/dist/exporter.d.ts +0 -42
- package/dist/exporter.d.ts.map +0 -1
- package/dist/exporter.js +0 -81
- package/dist/exporter.js.map +0 -1
- package/dist/trace-runner.d.ts +0 -72
- package/dist/trace-runner.d.ts.map +0 -1
- package/dist/trace-runner.js +0 -110
- package/dist/trace-runner.js.map +0 -1
- package/dist/tracer.d.ts +0 -152
- package/dist/tracer.d.ts.map +0 -1
- package/dist/tracer.js +0 -378
- package/dist/tracer.js.map +0 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.wrapAgent = exports.CandidatePromptManager = void 0;
|
|
4
4
|
var candidate_prompt_manager_1 = require("./candidate-prompt-manager");
|
|
5
5
|
Object.defineProperty(exports, "CandidatePromptManager", { enumerable: true, get: function () { return candidate_prompt_manager_1.CandidatePromptManager; } });
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "
|
|
6
|
+
var trace_wrapper_1 = require("./trace-wrapper");
|
|
7
|
+
Object.defineProperty(exports, "wrapAgent", { enumerable: true, get: function () { return trace_wrapper_1.wrapAgent; } });
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAA3D,kIAAA,sBAAsB,OAAA;AAC/B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAA3D,kIAAA,sBAAsB,OAAA;AAC/B,iDAA4C;AAAnC,0GAAA,SAAS,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-exporter.d.ts","sourceRoot":"","sources":["../src/memory-exporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEhF,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC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EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,MAAM,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,IAAI,CAAC;IACT,MAAM,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,CAAC,CAAC;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAE7C,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,gBAAgB,CAAA;KAAE,CAAC;IAKlE,QAAQ,IAAI,YAAY,EAAE;IAI1B,eAAe,IAAI,QAAQ,EAAE;IAI7B,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,EAAE;IAiB9C,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,WAAW;IAkDnB,KAAK,IAAI,IAAI;IAIb,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
|
package/dist/memory-exporter.js
CHANGED
|
@@ -19,6 +19,14 @@ class MemorySpanExporter {
|
|
|
19
19
|
}
|
|
20
20
|
getSpansByTraceId(traceId) {
|
|
21
21
|
const formattedTraceId = this._formatTraceId(traceId);
|
|
22
|
+
console.log(this._spans.map((span) => {
|
|
23
|
+
const spanDict = this._spanToDict(span);
|
|
24
|
+
return {
|
|
25
|
+
traceId: spanDict.trace_id,
|
|
26
|
+
spanId: spanDict.span_id,
|
|
27
|
+
parentSpanId: spanDict.parent_span_id,
|
|
28
|
+
};
|
|
29
|
+
}));
|
|
22
30
|
return this._spans
|
|
23
31
|
.map((span) => this._spanToDict(span))
|
|
24
32
|
.filter((span) => span.trace_id === formattedTraceId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-exporter.js","sourceRoot":"","sources":["../src/memory-exporter.ts"],"names":[],"mappings":";;;AAAA,8CAAuD;AA0BvD;;GAEG;AACH,MAAa,kBAAkB;IACZ,MAAM,GAAmB,EAAE,CAAC;IAE7C,MAAM,CAAC,KAAqB;QAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,uBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,iBAAiB,CAAC,OAAe;QAC/B,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"memory-exporter.js","sourceRoot":"","sources":["../src/memory-exporter.ts"],"names":[],"mappings":";;;AAAA,8CAAuD;AA0BvD;;GAEG;AACH,MAAa,kBAAkB;IACZ,MAAM,GAAmB,EAAE,CAAC;IAE7C,MAAM,CAAC,KAAqB;QAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,uBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7D,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xGD,gDAwGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-wrapper.d.ts","sourceRoot":"","sources":["../src/trace-wrapper.ts"],"names":[],"mappings":"AAGA,wBAAsB,SAAS,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;;;GAwBjI"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrapAgent = wrapAgent;
|
|
4
|
+
const api_1 = require("@opentelemetry/api");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
async function wrapAgent(agentName, fn, ...args) {
|
|
7
|
+
const tracer = api_1.trace.getTracer("app");
|
|
8
|
+
const runId = (0, uuid_1.v4)();
|
|
9
|
+
const span = tracer.startSpan(agentName, {
|
|
10
|
+
attributes: {
|
|
11
|
+
"lemma.run_id": runId,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
const ctx = api_1.trace.setSpan(api_1.context.active(), span);
|
|
15
|
+
try {
|
|
16
|
+
return await api_1.context.with(ctx, async () => {
|
|
17
|
+
const result = await fn(...args);
|
|
18
|
+
span.end();
|
|
19
|
+
return { result, runId };
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
span.recordException(err);
|
|
24
|
+
span.setStatus({ code: 2 });
|
|
25
|
+
span.end();
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=trace-wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-wrapper.js","sourceRoot":"","sources":["../src/trace-wrapper.ts"],"names":[],"mappings":";;AAGA,8BAwBC;AA3BD,4CAAoD;AACpD,+BAAoC;AAE7B,KAAK,UAAU,SAAS,CAA+D,SAAiB,EAAE,EAAK,EAAE,GAAG,IAAO;IAChI,MAAM,MAAM,GAAG,WAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAEtC,MAAM,KAAK,GAAG,IAAA,SAAM,GAAE,CAAC;IACvB,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE;QACvC,UAAU,EAAE;YACV,cAAc,EAAE,KAAK;SACtB;KACF,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,WAAK,CAAC,OAAO,CAAC,aAAO,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;IAElD,IAAI,CAAC;QACH,OAAO,MAAM,aAAO,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;YACxC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YACjC,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,CAAC,GAAY,CAAC,CAAC;QACnC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uselemma/tracing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "OpenTelemetry-based tracing module for Lemma",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Lemma",
|
|
@@ -30,19 +30,16 @@
|
|
|
30
30
|
"README.md",
|
|
31
31
|
"LICENSE"
|
|
32
32
|
],
|
|
33
|
-
"scripts": {
|
|
34
|
-
"type-check": "tsc --noEmit",
|
|
35
|
-
"build": "tsc",
|
|
36
|
-
"clean": "rm -rf dist",
|
|
37
|
-
"prepublishOnly": "pnpm run type-check && pnpm run build"
|
|
38
|
-
},
|
|
39
33
|
"dependencies": {
|
|
40
34
|
"@opentelemetry/api": "^1.9.0",
|
|
41
35
|
"@opentelemetry/context-async-hooks": "^2.2.0",
|
|
42
36
|
"@opentelemetry/core": "^2.2.0",
|
|
37
|
+
"@opentelemetry/exporter-trace-otlp-proto": "^0.211.0",
|
|
43
38
|
"@opentelemetry/resources": "^2.2.0",
|
|
44
39
|
"@opentelemetry/sdk-trace-base": "^2.2.0",
|
|
45
|
-
"
|
|
40
|
+
"@opentelemetry/sdk-trace-node": "^2.5.0",
|
|
41
|
+
"nunjucks": "^3.2.4",
|
|
42
|
+
"uuid": "^13.0.0"
|
|
46
43
|
},
|
|
47
44
|
"devDependencies": {
|
|
48
45
|
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
|
@@ -51,5 +48,10 @@
|
|
|
51
48
|
"prettier": "^3.6.2",
|
|
52
49
|
"prettier-plugin-tailwindcss": "^0.6.14",
|
|
53
50
|
"typescript": "^5.9.3"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"type-check": "tsc --noEmit",
|
|
54
|
+
"build": "tsc",
|
|
55
|
+
"clean": "rm -rf dist"
|
|
54
56
|
}
|
|
55
|
-
}
|
|
57
|
+
}
|
package/dist/exporter.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { ExportResultCode } from "@opentelemetry/core";
|
|
2
|
-
import type { ReadableSpan, SpanExporter } from "@opentelemetry/sdk-trace-base";
|
|
3
|
-
export interface SpanDict {
|
|
4
|
-
timestamp: string;
|
|
5
|
-
trace_id: string;
|
|
6
|
-
span_id: string;
|
|
7
|
-
parent_span_id: string | null;
|
|
8
|
-
name: string;
|
|
9
|
-
kind: string;
|
|
10
|
-
start_time_ns: string;
|
|
11
|
-
end_time_ns: string | null;
|
|
12
|
-
duration_ms: number | null;
|
|
13
|
-
attributes: Record<string, unknown>;
|
|
14
|
-
status: {
|
|
15
|
-
status_code: string;
|
|
16
|
-
description?: string;
|
|
17
|
-
} | null;
|
|
18
|
-
events: Array<{
|
|
19
|
-
name: string;
|
|
20
|
-
timestamp_ns: string;
|
|
21
|
-
attributes: Record<string, unknown>;
|
|
22
|
-
}>;
|
|
23
|
-
resource: Record<string, unknown>;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Span exporter that stores spans in memory for retrieval.
|
|
27
|
-
*/
|
|
28
|
-
export declare class MemorySpanExporter implements SpanExporter {
|
|
29
|
-
private readonly _spans;
|
|
30
|
-
export(spans: ReadableSpan[]): Promise<{
|
|
31
|
-
code: ExportResultCode;
|
|
32
|
-
}>;
|
|
33
|
-
getSpans(): ReadableSpan[];
|
|
34
|
-
getSpansAsDicts(): SpanDict[];
|
|
35
|
-
private _formatTraceId;
|
|
36
|
-
private _formatSpanId;
|
|
37
|
-
private _spanToDict;
|
|
38
|
-
clear(): void;
|
|
39
|
-
shutdown(): Promise<void>;
|
|
40
|
-
forceFlush(): Promise<void>;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=exporter.d.ts.map
|
package/dist/exporter.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../src/exporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEhF,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,MAAM,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,IAAI,CAAC;IACT,MAAM,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,CAAC,CAAC;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAE7C,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,gBAAgB,CAAA;KAAE,CAAC;IAKlE,QAAQ,IAAI,YAAY,EAAE;IAI1B,eAAe,IAAI,QAAQ,EAAE;IAI7B,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,WAAW;IAkDnB,KAAK,IAAI,IAAI;IAIb,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
|
package/dist/exporter.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MemorySpanExporter = void 0;
|
|
4
|
-
const core_1 = require("@opentelemetry/core");
|
|
5
|
-
/**
|
|
6
|
-
* Span exporter that stores spans in memory for retrieval.
|
|
7
|
-
*/
|
|
8
|
-
class MemorySpanExporter {
|
|
9
|
-
_spans = [];
|
|
10
|
-
export(spans) {
|
|
11
|
-
this._spans.push(...spans);
|
|
12
|
-
return Promise.resolve({ code: core_1.ExportResultCode.SUCCESS });
|
|
13
|
-
}
|
|
14
|
-
getSpans() {
|
|
15
|
-
return [...this._spans];
|
|
16
|
-
}
|
|
17
|
-
getSpansAsDicts() {
|
|
18
|
-
return this._spans.map((span) => this._spanToDict(span));
|
|
19
|
-
}
|
|
20
|
-
_formatTraceId(traceId) {
|
|
21
|
-
// Ensure trace ID is 32-character hex string
|
|
22
|
-
return traceId.padStart(32, "0").slice(0, 32);
|
|
23
|
-
}
|
|
24
|
-
_formatSpanId(spanId) {
|
|
25
|
-
// Ensure span ID is 16-character hex string
|
|
26
|
-
return spanId.padStart(16, "0").slice(0, 16);
|
|
27
|
-
}
|
|
28
|
-
_spanToDict(span) {
|
|
29
|
-
const spanCtx = span.spanContext();
|
|
30
|
-
const traceId = this._formatTraceId(spanCtx.traceId);
|
|
31
|
-
const spanId = this._formatSpanId(spanCtx.spanId);
|
|
32
|
-
const parentSpanId = span.parentSpanId
|
|
33
|
-
? this._formatSpanId(span.parentSpanId)
|
|
34
|
-
: null;
|
|
35
|
-
return {
|
|
36
|
-
timestamp: new Date().toISOString(),
|
|
37
|
-
trace_id: traceId,
|
|
38
|
-
span_id: spanId,
|
|
39
|
-
parent_span_id: parentSpanId,
|
|
40
|
-
name: span.name,
|
|
41
|
-
kind: span.kind.toString(),
|
|
42
|
-
start_time_ns: (BigInt(span.startTime[0]) * 1000000000n +
|
|
43
|
-
BigInt(span.startTime[1])).toString(),
|
|
44
|
-
end_time_ns: span.endTime
|
|
45
|
-
? (BigInt(span.endTime[0]) * 1000000000n +
|
|
46
|
-
BigInt(span.endTime[1])).toString()
|
|
47
|
-
: null,
|
|
48
|
-
duration_ms: span.endTime
|
|
49
|
-
? (span.endTime[0] - span.startTime[0]) * 1000 +
|
|
50
|
-
(span.endTime[1] - span.startTime[1]) / 1_000_000
|
|
51
|
-
: null,
|
|
52
|
-
attributes: span.attributes ? { ...span.attributes } : {},
|
|
53
|
-
status: span.status
|
|
54
|
-
? {
|
|
55
|
-
status_code: span.status.code.toString(),
|
|
56
|
-
description: span.status.message,
|
|
57
|
-
}
|
|
58
|
-
: null,
|
|
59
|
-
events: (span.events || []).map((event) => ({
|
|
60
|
-
name: event.name,
|
|
61
|
-
timestamp_ns: (BigInt(event.time[0]) * 1000000000n +
|
|
62
|
-
BigInt(event.time[1])).toString(),
|
|
63
|
-
attributes: event.attributes ? { ...event.attributes } : {},
|
|
64
|
-
})),
|
|
65
|
-
resource: span.resource?.attributes
|
|
66
|
-
? { ...span.resource.attributes }
|
|
67
|
-
: {},
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
clear() {
|
|
71
|
-
this._spans.length = 0;
|
|
72
|
-
}
|
|
73
|
-
shutdown() {
|
|
74
|
-
return Promise.resolve();
|
|
75
|
-
}
|
|
76
|
-
forceFlush() {
|
|
77
|
-
return Promise.resolve();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.MemorySpanExporter = MemorySpanExporter;
|
|
81
|
-
//# sourceMappingURL=exporter.js.map
|
package/dist/exporter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exporter.js","sourceRoot":"","sources":["../src/exporter.ts"],"names":[],"mappings":";;;AAAA,8CAAuD;AA0BvD;;GAEG;AACH,MAAa,kBAAkB;IACZ,MAAM,GAAmB,EAAE,CAAC;IAE7C,MAAM,CAAC,KAAqB;QAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,uBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,GA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AAQ,EAAE;gBACZ,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE;aAC5D,CAAC,CAAC;YACH,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU;gBACjC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;gBACjC,CAAC,CAAC,EAAE;SACP,CAAC;IACJ,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,QAAQ;QACN,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,UAAU;QACR,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF;AAvFD,gDAuFC"}
|
package/dist/trace-runner.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { Tracer } from "./tracer";
|
|
2
|
-
export interface TraceData {
|
|
3
|
-
trace_id: string;
|
|
4
|
-
spans: Array<{
|
|
5
|
-
timestamp: string;
|
|
6
|
-
trace_id: string;
|
|
7
|
-
span_id: string;
|
|
8
|
-
parent_span_id: string | null;
|
|
9
|
-
name: string;
|
|
10
|
-
kind: string;
|
|
11
|
-
start_time_ns: string;
|
|
12
|
-
end_time_ns: string | null;
|
|
13
|
-
duration_ms: number | null;
|
|
14
|
-
attributes: Record<string, unknown>;
|
|
15
|
-
status: {
|
|
16
|
-
status_code: string;
|
|
17
|
-
description?: string;
|
|
18
|
-
} | null;
|
|
19
|
-
events: Array<{
|
|
20
|
-
name: string;
|
|
21
|
-
timestamp_ns: string;
|
|
22
|
-
attributes: Record<string, unknown>;
|
|
23
|
-
}>;
|
|
24
|
-
resource: Record<string, unknown>;
|
|
25
|
-
}>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Wrapper around Tracer that manages candidate prompts and tracks trace_id.
|
|
29
|
-
*
|
|
30
|
-
* Usage:
|
|
31
|
-
* const traceRunner = new TraceRunner(tracer, { "prompt1": "..." });
|
|
32
|
-
*
|
|
33
|
-
* await traceRunner.run(async () => {
|
|
34
|
-
* // ... tracing code ...
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* const traceData = traceRunner.record();
|
|
38
|
-
* const traceId = traceData.trace_id;
|
|
39
|
-
* const spans = traceData.spans;
|
|
40
|
-
*/
|
|
41
|
-
export declare class TraceRunner {
|
|
42
|
-
private readonly _tracer;
|
|
43
|
-
private readonly _cpm;
|
|
44
|
-
private readonly _candidatePrompts;
|
|
45
|
-
private _traceId;
|
|
46
|
-
private _contextEntered;
|
|
47
|
-
private _alreadyRecorded;
|
|
48
|
-
constructor(tracer: Tracer, candidatePrompts?: Record<string, string> | null);
|
|
49
|
-
/**
|
|
50
|
-
* Run a callback with candidate prompts set in the async context.
|
|
51
|
-
*
|
|
52
|
-
* All spans created within this context will be part of the same trace.
|
|
53
|
-
* The trace_id is captured from spans created within the context and can be retrieved via record().
|
|
54
|
-
*
|
|
55
|
-
* @param callback - Function to run within the tracing context
|
|
56
|
-
* @returns Result of the callback
|
|
57
|
-
*/
|
|
58
|
-
run<T>(callback: () => Promise<T> | T): Promise<T>;
|
|
59
|
-
/**
|
|
60
|
-
* Set the trace_id manually. This can be called after run() to explicitly set the trace.
|
|
61
|
-
* Normally not needed as record() will auto-detect from spans.
|
|
62
|
-
*/
|
|
63
|
-
setTraceId(traceId: string): void;
|
|
64
|
-
/**
|
|
65
|
-
* Export all spans and return the full trace with all child spans.
|
|
66
|
-
*
|
|
67
|
-
* @returns Dictionary with trace_id and spans
|
|
68
|
-
* @throws Error if called before context is entered or after already recorded
|
|
69
|
-
*/
|
|
70
|
-
record(): Promise<TraceData>;
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=trace-runner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trace-runner.d.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EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAWlD;;;;;;;;OAQG;IACG,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IA4BxD;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIjC;;;;;OAKG;IACG,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC;CAyCnC"}
|
package/dist/trace-runner.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TraceRunner = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Wrapper around Tracer that manages candidate prompts and tracks trace_id.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* const traceRunner = new TraceRunner(tracer, { "prompt1": "..." });
|
|
9
|
-
*
|
|
10
|
-
* await traceRunner.run(async () => {
|
|
11
|
-
* // ... tracing code ...
|
|
12
|
-
* });
|
|
13
|
-
*
|
|
14
|
-
* const traceData = traceRunner.record();
|
|
15
|
-
* const traceId = traceData.trace_id;
|
|
16
|
-
* const spans = traceData.spans;
|
|
17
|
-
*/
|
|
18
|
-
class TraceRunner {
|
|
19
|
-
_tracer;
|
|
20
|
-
_cpm;
|
|
21
|
-
_candidatePrompts;
|
|
22
|
-
_traceId;
|
|
23
|
-
_contextEntered = false;
|
|
24
|
-
_alreadyRecorded = false;
|
|
25
|
-
constructor(tracer, candidatePrompts) {
|
|
26
|
-
this._tracer = tracer;
|
|
27
|
-
// Use the tracer's CandidatePromptManager to ensure shared context
|
|
28
|
-
this._cpm = tracer.getCandidatePromptManager();
|
|
29
|
-
this._candidatePrompts = candidatePrompts ?? null;
|
|
30
|
-
this._traceId = undefined;
|
|
31
|
-
this._contextEntered = false;
|
|
32
|
-
this._alreadyRecorded = false;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Run a callback with candidate prompts set in the async context.
|
|
36
|
-
*
|
|
37
|
-
* All spans created within this context will be part of the same trace.
|
|
38
|
-
* The trace_id is captured from spans created within the context and can be retrieved via record().
|
|
39
|
-
*
|
|
40
|
-
* @param callback - Function to run within the tracing context
|
|
41
|
-
* @returns Result of the callback
|
|
42
|
-
*/
|
|
43
|
-
async run(callback) {
|
|
44
|
-
if (this._alreadyRecorded) {
|
|
45
|
-
throw new Error("Cannot enter context after record() has been called");
|
|
46
|
-
}
|
|
47
|
-
// Set up candidate prompts context
|
|
48
|
-
const result = await this._cpm.run(this._candidatePrompts, async () => {
|
|
49
|
-
this._contextEntered = true;
|
|
50
|
-
try {
|
|
51
|
-
return await callback();
|
|
52
|
-
}
|
|
53
|
-
finally {
|
|
54
|
-
// Reset state when context exits
|
|
55
|
-
this._contextEntered = false;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
// Capture trace_id from the most recent span after execution
|
|
59
|
-
await this._tracer.forceFlush();
|
|
60
|
-
const spans = this._tracer.getMemoryExporter().getSpansAsDicts();
|
|
61
|
-
if (spans.length > 0 && this._traceId === undefined) {
|
|
62
|
-
// Get trace_id from the most recently created span
|
|
63
|
-
this._traceId = spans[spans.length - 1].trace_id;
|
|
64
|
-
}
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Set the trace_id manually. This can be called after run() to explicitly set the trace.
|
|
69
|
-
* Normally not needed as record() will auto-detect from spans.
|
|
70
|
-
*/
|
|
71
|
-
setTraceId(traceId) {
|
|
72
|
-
this._traceId = traceId;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Export all spans and return the full trace with all child spans.
|
|
76
|
-
*
|
|
77
|
-
* @returns Dictionary with trace_id and spans
|
|
78
|
-
* @throws Error if called before context is entered or after already recorded
|
|
79
|
-
*/
|
|
80
|
-
async record() {
|
|
81
|
-
if (this._alreadyRecorded) {
|
|
82
|
-
throw new Error("record() can only be called once per TraceRunner instance");
|
|
83
|
-
}
|
|
84
|
-
// Capture trace_id if we haven't yet
|
|
85
|
-
if (this._traceId === undefined) {
|
|
86
|
-
// Try to get from any span in the exporter
|
|
87
|
-
const allSpans = this._tracer.getMemoryExporter().getSpansAsDicts();
|
|
88
|
-
if (allSpans.length > 0) {
|
|
89
|
-
// Get the most recent span's trace_id
|
|
90
|
-
this._traceId = allSpans[allSpans.length - 1].trace_id;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (this._traceId === undefined) {
|
|
94
|
-
throw new Error("trace_id could not be captured. Ensure spans are created within the context.");
|
|
95
|
-
}
|
|
96
|
-
// Force flush all pending spans
|
|
97
|
-
await this._tracer.forceFlush();
|
|
98
|
-
// Get all spans for this trace
|
|
99
|
-
const allSpans = this._tracer.getMemoryExporter().getSpansAsDicts();
|
|
100
|
-
// Filter spans to only include those matching the trace_id
|
|
101
|
-
const traceSpans = allSpans.filter((span) => span.trace_id === this._traceId);
|
|
102
|
-
this._alreadyRecorded = true;
|
|
103
|
-
return {
|
|
104
|
-
trace_id: this._traceId,
|
|
105
|
-
spans: traceSpans,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.TraceRunner = TraceRunner;
|
|
110
|
-
//# sourceMappingURL=trace-runner.js.map
|
package/dist/trace-runner.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trace-runner.js","sourceRoot":"","sources":["../src/trace-runner.ts"],"names":[],"mappings":";;;AA8BA;;;;;;;;;;;;;GAaG;AACH,MAAa,WAAW;IACL,OAAO,CAAS;IAChB,IAAI,CAAyB;IAC7B,iBAAiB,CAAgC;IAC1D,QAAQ,CAAqB;IAC7B,eAAe,GAAG,KAAK,CAAC;IACxB,gBAAgB,GAAG,KAAK,CAAC;IAEjC,YACE,MAAc,EACd,gBAAgD;QAEhD,IAAI,CAAC,OAAO,GAAG,MAAM,CA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|
|
1
|
-
import { type Span } from "@opentelemetry/api";
|
|
2
|
-
import type { SpanExporter } from "@opentelemetry/sdk-trace-base";
|
|
3
|
-
import { CandidatePromptManager } from "./candidate-prompt-manager";
|
|
4
|
-
import { MemorySpanExporter } from "./exporter";
|
|
5
|
-
type AnyFunction<TArgs extends unknown[] = unknown[], TReturn = unknown> = (...args: TArgs) => TReturn;
|
|
6
|
-
/**
|
|
7
|
-
* Span type for tracing different kinds of operations.
|
|
8
|
-
*/
|
|
9
|
-
export declare enum SpanType {
|
|
10
|
-
AGENT = "agent",
|
|
11
|
-
NODE = "node",
|
|
12
|
-
TOOL = "tool"
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* OpenTelemetry-based tracer that mimics agentbridge API.
|
|
16
|
-
*/
|
|
17
|
-
export declare class Tracer {
|
|
18
|
-
private readonly _tracer;
|
|
19
|
-
private readonly _cpm;
|
|
20
|
-
private readonly _memoryExporter;
|
|
21
|
-
private readonly _provider;
|
|
22
|
-
private readonly _currentPromptSpan;
|
|
23
|
-
private readonly _llmStartTime;
|
|
24
|
-
constructor(serviceName: string, exporter?: SpanExporter, candidatePromptManager?: CandidatePromptManager);
|
|
25
|
-
/**
|
|
26
|
-
* Wraps a function to trace it as a span.
|
|
27
|
-
*
|
|
28
|
-
* @param spanType - Type of span (SpanType.AGENT, SpanType.NODE, or SpanType.TOOL)
|
|
29
|
-
* @param func - Function to wrap
|
|
30
|
-
* @returns Wrapped function
|
|
31
|
-
*/
|
|
32
|
-
wrap<TArgs extends unknown[], TReturn>(spanType: SpanType, func: AnyFunction<TArgs, TReturn>): AnyFunction<TArgs, TReturn>;
|
|
33
|
-
/**
|
|
34
|
-
* Context manager for tracing prompt rendering and LLM calls.
|
|
35
|
-
*
|
|
36
|
-
* Usage:
|
|
37
|
-
* const renderedPrompt = await tracer.prompt(
|
|
38
|
-
* "translation",
|
|
39
|
-
* promptTemplate,
|
|
40
|
-
* { premises: [...], conclusion: "..." }
|
|
41
|
-
* );
|
|
42
|
-
* const result = await llm.invoke([{ role: "user", content: renderedPrompt }]);
|
|
43
|
-
* tracer.addLlmOutput(result.content);
|
|
44
|
-
*
|
|
45
|
-
* @param promptName - Name of the prompt
|
|
46
|
-
* @param promptTemplate - Template string (Nunjucks format)
|
|
47
|
-
* @param inputVars - Variables to render into the template
|
|
48
|
-
* @returns Promise that resolves to the rendered prompt
|
|
49
|
-
*/
|
|
50
|
-
prompt(promptName: string, promptTemplate: string, inputVars: Record<string, unknown>): Promise<string>;
|
|
51
|
-
/**
|
|
52
|
-
* Start a prompt span and return a context manager-like object.
|
|
53
|
-
*
|
|
54
|
-
* Usage:
|
|
55
|
-
* const promptCtx = tracer.startPrompt("translation", template, vars);
|
|
56
|
-
* const renderedPrompt = promptCtx.renderedPrompt;
|
|
57
|
-
* // ... use renderedPrompt ...
|
|
58
|
-
* tracer.addLlmOutput(result.content);
|
|
59
|
-
* promptCtx.end();
|
|
60
|
-
*
|
|
61
|
-
* @param promptName - Name of the prompt
|
|
62
|
-
* @param promptTemplate - Template string (Nunjucks format)
|
|
63
|
-
* @param inputVars - Variables to render into the template
|
|
64
|
-
* @returns Object with renderedPrompt and end() method
|
|
65
|
-
*/
|
|
66
|
-
startPrompt(promptName: string, promptTemplate: string, inputVars: Record<string, unknown>): {
|
|
67
|
-
renderedPrompt: string;
|
|
68
|
-
span: Span;
|
|
69
|
-
end: () => void;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Add LLM output metadata to the current prompt span.
|
|
73
|
-
*
|
|
74
|
-
* Usage:
|
|
75
|
-
* tracer.addLLMOutput(result.content);
|
|
76
|
-
* // or with more metadata:
|
|
77
|
-
* tracer.addLlmOutput(
|
|
78
|
-
* result.content,
|
|
79
|
-
* "gpt-4",
|
|
80
|
-
* { prompt_tokens: 100, completion_tokens: 50 }
|
|
81
|
-
* );
|
|
82
|
-
*
|
|
83
|
-
* @param output - LLM output text
|
|
84
|
-
* @param model - Optional model name
|
|
85
|
-
* @param usage - Optional token usage information
|
|
86
|
-
*/
|
|
87
|
-
addLLMOutput(output: string, model?: string, usage?: {
|
|
88
|
-
prompt_tokens?: number;
|
|
89
|
-
completion_tokens?: number;
|
|
90
|
-
total_tokens?: number;
|
|
91
|
-
}): void;
|
|
92
|
-
/**
|
|
93
|
-
* Get the current active span.
|
|
94
|
-
*
|
|
95
|
-
* @returns Current span or undefined
|
|
96
|
-
*/
|
|
97
|
-
getCurrentSpan(): Span | undefined;
|
|
98
|
-
/**
|
|
99
|
-
* Add metadata to the current span.
|
|
100
|
-
*
|
|
101
|
-
* Usage:
|
|
102
|
-
* tracer.addMetadata("decision", "True");
|
|
103
|
-
*
|
|
104
|
-
* @param key - Attribute key
|
|
105
|
-
* @param value - Attribute value
|
|
106
|
-
*/
|
|
107
|
-
addMetadata(key: string, value: unknown): void;
|
|
108
|
-
/**
|
|
109
|
-
* Add an event to the current span.
|
|
110
|
-
*
|
|
111
|
-
* Usage:
|
|
112
|
-
* tracer.addEvent("processing_started", { item_count: 10 });
|
|
113
|
-
*
|
|
114
|
-
* @param eventName - Name of the event
|
|
115
|
-
* @param attributes - Optional event attributes
|
|
116
|
-
*/
|
|
117
|
-
addEvent(eventName: string, attributes?: Record<string, string | number | boolean>): void;
|
|
118
|
-
/**
|
|
119
|
-
* Get the trace_id from the current active span.
|
|
120
|
-
*
|
|
121
|
-
* @returns trace_id as a 32-character hexadecimal string, or undefined if not available
|
|
122
|
-
*/
|
|
123
|
-
getTraceId(): string | undefined;
|
|
124
|
-
/**
|
|
125
|
-
* Helper to format trace ID as 32-character hex string.
|
|
126
|
-
*/
|
|
127
|
-
private _formatTraceId;
|
|
128
|
-
/**
|
|
129
|
-
* Force flush all pending spans.
|
|
130
|
-
*/
|
|
131
|
-
forceFlush(): Promise<void>;
|
|
132
|
-
/**
|
|
133
|
-
* Get the candidate prompt manager instance.
|
|
134
|
-
*
|
|
135
|
-
* @returns The CandidatePromptManager instance used by this tracer
|
|
136
|
-
*/
|
|
137
|
-
getCandidatePromptManager(): CandidatePromptManager;
|
|
138
|
-
/**
|
|
139
|
-
* Get the memory exporter instance.
|
|
140
|
-
* This is used internally by TraceRunner to access collected spans.
|
|
141
|
-
*
|
|
142
|
-
* @returns The MemorySpanExporter instance
|
|
143
|
-
*/
|
|
144
|
-
getMemoryExporter(): MemorySpanExporter;
|
|
145
|
-
/**
|
|
146
|
-
* Clear all spans from memory exporter.
|
|
147
|
-
* Useful for cleaning up between test runs.
|
|
148
|
-
*/
|
|
149
|
-
clearSpans(): void;
|
|
150
|
-
}
|
|
151
|
-
export {};
|
|
152
|
-
//# sourceMappingURL=tracer.d.ts.map
|
package/dist/tracer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../src/tracer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,IAAI,EAAyB,MAAM,oBAAoB,CAAC;AAG/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAQlE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAKhD,KAAK,WAAW,CAAC,KAAK,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EAAE,OAAO,GAAG,OAAO,IAAI,CACzE,GAAG,IAAI,EAAE,KAAK,KACX,OAAO,CAAC;AAEb;;GAEG;AACH,oBAAY,QAAQ;IAClB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqC;IAC7D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAyB;IAC9C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IACrD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsB;IAChD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA2C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,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GACrD,IAAI;IAOP;;;;OAIG;IACH,UAAU,IAAI,MAAM,GAAG,SAAS;IAQhC;;OAEG;IACH,OAAO,CAAC,cAAc;IAKtB;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC;;;;OAIG;IACH,yBAAyB,IAAI,sBAAsB;IAInD;;;;;OAKG;IACH,iBAAiB,IAAI,kBAAkB;IAIvC;;;OAGG;IACH,UAAU,IAAI,IAAI;CAGnB"}
|
package/dist/tracer.js
DELETED
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Tracer = exports.SpanType = void 0;
|
|
7
|
-
const api_1 = require("@opentelemetry/api");
|
|
8
|
-
const context_async_hooks_1 = require("@opentelemetry/context-async-hooks");
|
|
9
|
-
const resources_1 = require("@opentelemetry/resources");
|
|
10
|
-
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
11
|
-
const node_async_hooks_1 = require("node:async_hooks");
|
|
12
|
-
const nunjucks_1 = __importDefault(require("nunjucks"));
|
|
13
|
-
const candidate_prompt_manager_1 = require("./candidate-prompt-manager");
|
|
14
|
-
const exporter_1 = require("./exporter");
|
|
15
|
-
// Track if global context manager has been initialized
|
|
16
|
-
let globalContextManagerInitialized = false;
|
|
17
|
-
/**
|
|
18
|
-
* Span type for tracing different kinds of operations.
|
|
19
|
-
*/
|
|
20
|
-
var SpanType;
|
|
21
|
-
(function (SpanType) {
|
|
22
|
-
SpanType["AGENT"] = "agent";
|
|
23
|
-
SpanType["NODE"] = "node";
|
|
24
|
-
SpanType["TOOL"] = "tool";
|
|
25
|
-
})(SpanType || (exports.SpanType = SpanType = {}));
|
|
26
|
-
/**
|
|
27
|
-
* OpenTelemetry-based tracer that mimics agentbridge API.
|
|
28
|
-
*/
|
|
29
|
-
class Tracer {
|
|
30
|
-
_tracer;
|
|
31
|
-
_cpm;
|
|
32
|
-
_memoryExporter;
|
|
33
|
-
_provider;
|
|
34
|
-
_currentPromptSpan;
|
|
35
|
-
_llmStartTime;
|
|
36
|
-
constructor(serviceName, exporter, candidatePromptManager) {
|
|
37
|
-
const resource = resources_1.Resource.default().merge(new resources_1.Resource({
|
|
38
|
-
"service.name": serviceName,
|
|
39
|
-
}));
|
|
40
|
-
// Always create a memory exporter for TraceRunner to use
|
|
41
|
-
this._memoryExporter = new exporter_1.MemorySpanExporter();
|
|
42
|
-
// Prepare span processors
|
|
43
|
-
const spanProcessors = [
|
|
44
|
-
new sdk_trace_base_1.SimpleSpanProcessor(this._memoryExporter),
|
|
45
|
-
];
|
|
46
|
-
if (exporter) {
|
|
47
|
-
spanProcessors.push(new sdk_trace_base_1.SimpleSpanProcessor(exporter));
|
|
48
|
-
}
|
|
49
|
-
// Set up context manager for async context propagation (only once globally)
|
|
50
|
-
if (!globalContextManagerInitialized) {
|
|
51
|
-
const contextManager = new context_async_hooks_1.AsyncLocalStorageContextManager();
|
|
52
|
-
contextManager.enable();
|
|
53
|
-
api_1.context.setGlobalContextManager(contextManager);
|
|
54
|
-
globalContextManagerInitialized = true;
|
|
55
|
-
}
|
|
56
|
-
// Create provider with span processors
|
|
57
|
-
this._provider = new sdk_trace_base_1.BasicTracerProvider({
|
|
58
|
-
resource,
|
|
59
|
-
spanProcessors,
|
|
60
|
-
});
|
|
61
|
-
// Register provider globally (this will overwrite any previous registration,
|
|
62
|
-
// but we use the provider's getTracer method directly to ensure spans go to
|
|
63
|
-
// this provider's processors)
|
|
64
|
-
this._provider.register();
|
|
65
|
-
// Use the provider's getTracer method directly to ensure spans are processed
|
|
66
|
-
// by this provider's span processors (including this tracer's memory exporter)
|
|
67
|
-
this._tracer = this._provider.getTracer(serviceName);
|
|
68
|
-
this._cpm = candidatePromptManager ?? new candidate_prompt_manager_1.CandidatePromptManager();
|
|
69
|
-
// Context-local state for prompt spans and timing
|
|
70
|
-
this._currentPromptSpan = new node_async_hooks_1.AsyncLocalStorage();
|
|
71
|
-
this._llmStartTime = new node_async_hooks_1.AsyncLocalStorage();
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Wraps a function to trace it as a span.
|
|
75
|
-
*
|
|
76
|
-
* @param spanType - Type of span (SpanType.AGENT, SpanType.NODE, or SpanType.TOOL)
|
|
77
|
-
* @param func - Function to wrap
|
|
78
|
-
* @returns Wrapped function
|
|
79
|
-
*/
|
|
80
|
-
wrap(spanType, func) {
|
|
81
|
-
const wrapped = ((...args) => {
|
|
82
|
-
// Capture the current context so the span inherits the parent's trace_id
|
|
83
|
-
const currentContext = api_1.context.active();
|
|
84
|
-
const span = this._tracer.startSpan(func.name, undefined, currentContext);
|
|
85
|
-
const activeContext = api_1.trace.setSpan(currentContext, span);
|
|
86
|
-
span.setAttribute("span.type", spanType);
|
|
87
|
-
span.setAttribute("function.name", func.name);
|
|
88
|
-
// Add input metadata for agent spans
|
|
89
|
-
const inputArgs = args.slice(0);
|
|
90
|
-
try {
|
|
91
|
-
span.setAttribute("function.input", JSON.stringify(inputArgs));
|
|
92
|
-
}
|
|
93
|
-
catch {
|
|
94
|
-
// Skip if args can't be serialized
|
|
95
|
-
}
|
|
96
|
-
return api_1.context.with(activeContext, () => {
|
|
97
|
-
try {
|
|
98
|
-
const result = func(...args);
|
|
99
|
-
if (result instanceof Promise) {
|
|
100
|
-
return result
|
|
101
|
-
.then((res) => {
|
|
102
|
-
try {
|
|
103
|
-
span.setAttribute("function.result", JSON.stringify(res));
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
// Skip if result can't be serialized
|
|
107
|
-
}
|
|
108
|
-
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
109
|
-
span.end();
|
|
110
|
-
return res;
|
|
111
|
-
})
|
|
112
|
-
.catch((error) => {
|
|
113
|
-
span.setStatus({
|
|
114
|
-
code: api_1.SpanStatusCode.ERROR,
|
|
115
|
-
message: error.message,
|
|
116
|
-
});
|
|
117
|
-
span.recordException(error);
|
|
118
|
-
span.end();
|
|
119
|
-
throw error;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
try {
|
|
123
|
-
span.setAttribute("function.result", JSON.stringify(result));
|
|
124
|
-
}
|
|
125
|
-
catch {
|
|
126
|
-
// Skip if result can't be serialized
|
|
127
|
-
}
|
|
128
|
-
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
129
|
-
span.end();
|
|
130
|
-
return result;
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
134
|
-
span.setStatus({
|
|
135
|
-
code: api_1.SpanStatusCode.ERROR,
|
|
136
|
-
message: err.message,
|
|
137
|
-
});
|
|
138
|
-
span.recordException(err);
|
|
139
|
-
span.end();
|
|
140
|
-
throw error;
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
Object.defineProperty(wrapped, "name", { value: func.name });
|
|
145
|
-
return wrapped;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Context manager for tracing prompt rendering and LLM calls.
|
|
149
|
-
*
|
|
150
|
-
* Usage:
|
|
151
|
-
* const renderedPrompt = await tracer.prompt(
|
|
152
|
-
* "translation",
|
|
153
|
-
* promptTemplate,
|
|
154
|
-
* { premises: [...], conclusion: "..." }
|
|
155
|
-
* );
|
|
156
|
-
* const result = await llm.invoke([{ role: "user", content: renderedPrompt }]);
|
|
157
|
-
* tracer.addLlmOutput(result.content);
|
|
158
|
-
*
|
|
159
|
-
* @param promptName - Name of the prompt
|
|
160
|
-
* @param promptTemplate - Template string (Nunjucks format)
|
|
161
|
-
* @param inputVars - Variables to render into the template
|
|
162
|
-
* @returns Promise that resolves to the rendered prompt
|
|
163
|
-
*/
|
|
164
|
-
async prompt(promptName, promptTemplate, inputVars) {
|
|
165
|
-
const currentContext = api_1.context.active();
|
|
166
|
-
const span = this._tracer.startSpan(promptName, undefined, currentContext);
|
|
167
|
-
const activeContext = api_1.trace.setSpan(currentContext, span);
|
|
168
|
-
span.setAttribute("span.type", "prompt");
|
|
169
|
-
span.setAttribute("prompt.name", promptName);
|
|
170
|
-
span.setAttribute("prompt.template", promptTemplate);
|
|
171
|
-
span.setAttribute("prompt.input_vars", JSON.stringify(inputVars));
|
|
172
|
-
// Select effective template (apply candidate override if present) and render
|
|
173
|
-
const [effectiveTemplate, overrideApplied] = this._cpm.getEffectiveTemplate(promptName, promptTemplate);
|
|
174
|
-
span.setAttribute("prompt.override_applied", overrideApplied);
|
|
175
|
-
const renderedPrompt = nunjucks_1.default.renderString(effectiveTemplate, inputVars);
|
|
176
|
-
span.setAttribute("prompt.rendered_length", renderedPrompt.length);
|
|
177
|
-
span.addEvent("prompt_rendered");
|
|
178
|
-
const startTime = Date.now();
|
|
179
|
-
// Store span and start time in context for add_llm_output to use
|
|
180
|
-
// Use run() to ensure these are available in the async context
|
|
181
|
-
return this._currentPromptSpan.run({ span }, () => {
|
|
182
|
-
return this._llmStartTime.run({ time: startTime }, () => {
|
|
183
|
-
// Return the rendered prompt with active context
|
|
184
|
-
// The span and time will be available when addLlmOutput is called
|
|
185
|
-
// as long as it's called within this async context
|
|
186
|
-
return api_1.context.with(activeContext, async () => {
|
|
187
|
-
return renderedPrompt;
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Start a prompt span and return a context manager-like object.
|
|
194
|
-
*
|
|
195
|
-
* Usage:
|
|
196
|
-
* const promptCtx = tracer.startPrompt("translation", template, vars);
|
|
197
|
-
* const renderedPrompt = promptCtx.renderedPrompt;
|
|
198
|
-
* // ... use renderedPrompt ...
|
|
199
|
-
* tracer.addLlmOutput(result.content);
|
|
200
|
-
* promptCtx.end();
|
|
201
|
-
*
|
|
202
|
-
* @param promptName - Name of the prompt
|
|
203
|
-
* @param promptTemplate - Template string (Nunjucks format)
|
|
204
|
-
* @param inputVars - Variables to render into the template
|
|
205
|
-
* @returns Object with renderedPrompt and end() method
|
|
206
|
-
*/
|
|
207
|
-
startPrompt(promptName, promptTemplate, inputVars) {
|
|
208
|
-
const currentContext = api_1.context.active();
|
|
209
|
-
const span = this._tracer.startSpan(promptName, undefined, currentContext);
|
|
210
|
-
const activeContext = api_1.trace.setSpan(currentContext, span);
|
|
211
|
-
span.setAttribute("span.type", "prompt");
|
|
212
|
-
span.setAttribute("prompt.name", promptName);
|
|
213
|
-
span.setAttribute("prompt.template", promptTemplate);
|
|
214
|
-
span.setAttribute("prompt.input_vars", JSON.stringify(inputVars));
|
|
215
|
-
// Select effective template (apply candidate override if present) and render
|
|
216
|
-
const [effectiveTemplate, overrideApplied] = this._cpm.getEffectiveTemplate(promptName, promptTemplate);
|
|
217
|
-
span.setAttribute("prompt.override_applied", overrideApplied);
|
|
218
|
-
const renderedPrompt = nunjucks_1.default.renderString(effectiveTemplate, inputVars);
|
|
219
|
-
span.setAttribute("prompt.rendered_length", renderedPrompt.length);
|
|
220
|
-
span.addEvent("prompt_rendered");
|
|
221
|
-
const startTime = Date.now();
|
|
222
|
-
// Store span and start time in context for add_llm_output to use
|
|
223
|
-
// Note: These will only be available if addLlmOutput is called
|
|
224
|
-
// within the same async context chain
|
|
225
|
-
this._currentPromptSpan.enterWith({ span });
|
|
226
|
-
this._llmStartTime.enterWith({ time: startTime });
|
|
227
|
-
return {
|
|
228
|
-
renderedPrompt,
|
|
229
|
-
span,
|
|
230
|
-
end: () => {
|
|
231
|
-
span.end();
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Add LLM output metadata to the current prompt span.
|
|
237
|
-
*
|
|
238
|
-
* Usage:
|
|
239
|
-
* tracer.addLLMOutput(result.content);
|
|
240
|
-
* // or with more metadata:
|
|
241
|
-
* tracer.addLlmOutput(
|
|
242
|
-
* result.content,
|
|
243
|
-
* "gpt-4",
|
|
244
|
-
* { prompt_tokens: 100, completion_tokens: 50 }
|
|
245
|
-
* );
|
|
246
|
-
*
|
|
247
|
-
* @param output - LLM output text
|
|
248
|
-
* @param model - Optional model name
|
|
249
|
-
* @param usage - Optional token usage information
|
|
250
|
-
*/
|
|
251
|
-
addLLMOutput(output, model, usage) {
|
|
252
|
-
const store = this._currentPromptSpan.getStore();
|
|
253
|
-
const timeStore = this._llmStartTime.getStore();
|
|
254
|
-
const span = store?.span ?? null;
|
|
255
|
-
const startTime = timeStore?.time ?? null;
|
|
256
|
-
if (!span || startTime === null) {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
const durationMs = Date.now() - startTime;
|
|
260
|
-
span.setAttribute("gen_ai.response", output.slice(0, 1000)); // Truncate
|
|
261
|
-
span.setAttribute("gen_ai.response.length", output.length);
|
|
262
|
-
span.setAttribute("llm.duration_ms", durationMs);
|
|
263
|
-
if (model) {
|
|
264
|
-
span.setAttribute("gen_ai.request.model", model);
|
|
265
|
-
}
|
|
266
|
-
if (usage) {
|
|
267
|
-
span.setAttribute("gen_ai.usage.prompt_tokens", usage.prompt_tokens ?? 0);
|
|
268
|
-
span.setAttribute("gen_ai.usage.completion_tokens", usage.completion_tokens ?? 0);
|
|
269
|
-
span.setAttribute("gen_ai.usage.total_tokens", usage.total_tokens ?? 0);
|
|
270
|
-
}
|
|
271
|
-
span.addEvent("llm_call_completed", {
|
|
272
|
-
duration_ms: durationMs,
|
|
273
|
-
response_length: output.length,
|
|
274
|
-
});
|
|
275
|
-
span.end();
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Get the current active span.
|
|
279
|
-
*
|
|
280
|
-
* @returns Current span or undefined
|
|
281
|
-
*/
|
|
282
|
-
getCurrentSpan() {
|
|
283
|
-
const span = api_1.trace.getActiveSpan();
|
|
284
|
-
return span;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Add metadata to the current span.
|
|
288
|
-
*
|
|
289
|
-
* Usage:
|
|
290
|
-
* tracer.addMetadata("decision", "True");
|
|
291
|
-
*
|
|
292
|
-
* @param key - Attribute key
|
|
293
|
-
* @param value - Attribute value
|
|
294
|
-
*/
|
|
295
|
-
addMetadata(key, value) {
|
|
296
|
-
const span = this.getCurrentSpan();
|
|
297
|
-
if (span) {
|
|
298
|
-
if (typeof value === "string" ||
|
|
299
|
-
typeof value === "number" ||
|
|
300
|
-
typeof value === "boolean") {
|
|
301
|
-
span.setAttribute(key, value);
|
|
302
|
-
}
|
|
303
|
-
else if (Array.isArray(value) || typeof value === "object") {
|
|
304
|
-
const serialized = JSON.stringify(value);
|
|
305
|
-
span.setAttribute(key, serialized.slice(0, 1000));
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
span.setAttribute(key, String(value).slice(0, 1000));
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Add an event to the current span.
|
|
314
|
-
*
|
|
315
|
-
* Usage:
|
|
316
|
-
* tracer.addEvent("processing_started", { item_count: 10 });
|
|
317
|
-
*
|
|
318
|
-
* @param eventName - Name of the event
|
|
319
|
-
* @param attributes - Optional event attributes
|
|
320
|
-
*/
|
|
321
|
-
addEvent(eventName, attributes) {
|
|
322
|
-
const span = this.getCurrentSpan();
|
|
323
|
-
if (span) {
|
|
324
|
-
span.addEvent(eventName, attributes);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Get the trace_id from the current active span.
|
|
329
|
-
*
|
|
330
|
-
* @returns trace_id as a 32-character hexadecimal string, or undefined if not available
|
|
331
|
-
*/
|
|
332
|
-
getTraceId() {
|
|
333
|
-
const span = this.getCurrentSpan();
|
|
334
|
-
if (span) {
|
|
335
|
-
return this._formatTraceId(span.spanContext().traceId);
|
|
336
|
-
}
|
|
337
|
-
return undefined;
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Helper to format trace ID as 32-character hex string.
|
|
341
|
-
*/
|
|
342
|
-
_formatTraceId(traceId) {
|
|
343
|
-
// Trace ID from OpenTelemetry is already a hex string, but ensure it's 32 chars
|
|
344
|
-
return traceId.padStart(32, "0").slice(0, 32);
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Force flush all pending spans.
|
|
348
|
-
*/
|
|
349
|
-
async forceFlush() {
|
|
350
|
-
await this._provider.forceFlush();
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Get the candidate prompt manager instance.
|
|
354
|
-
*
|
|
355
|
-
* @returns The CandidatePromptManager instance used by this tracer
|
|
356
|
-
*/
|
|
357
|
-
getCandidatePromptManager() {
|
|
358
|
-
return this._cpm;
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Get the memory exporter instance.
|
|
362
|
-
* This is used internally by TraceRunner to access collected spans.
|
|
363
|
-
*
|
|
364
|
-
* @returns The MemorySpanExporter instance
|
|
365
|
-
*/
|
|
366
|
-
getMemoryExporter() {
|
|
367
|
-
return this._memoryExporter;
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Clear all spans from memory exporter.
|
|
371
|
-
* Useful for cleaning up between test runs.
|
|
372
|
-
*/
|
|
373
|
-
clearSpans() {
|
|
374
|
-
this._memoryExporter.clear();
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
exports.Tracer = Tracer;
|
|
378
|
-
//# sourceMappingURL=tracer.js.map
|
package/dist/tracer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tracer.js","sourceRoot":"","sources":["../src/tracer.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+E;AAC/E,4EAAqF;AACrF,wDAAoD;AAEpD,kEAGuC;AACvC,uDAAqD;AACrD,wDAAgC;AAEhC,yEAAoE;AACpE,yCAAgD;AAEhD,uDAAuD;AACvD,IAAI,+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