langsmith 0.3.44 → 0.3.46-rc.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/client.d.ts +2 -2
- package/dist/experimental/otel/exporter.cjs +22 -10
- package/dist/experimental/otel/exporter.d.ts +5 -0
- package/dist/experimental/otel/exporter.js +22 -10
- package/dist/experimental/otel/translator.cjs +2 -2
- package/dist/experimental/otel/translator.js +2 -2
- package/dist/experimental/otel/types.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/run_trees.cjs +25 -7
- package/dist/run_trees.d.ts +8 -3
- package/dist/run_trees.js +25 -7
- package/dist/schemas.d.ts +3 -3
- package/dist/traceable.cjs +5 -2
- package/dist/traceable.js +6 -3
- package/dist/utils/jestlike/index.cjs +1 -1
- package/dist/utils/jestlike/index.js +1 -1
- package/dist/utils/jestlike/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -187,8 +187,8 @@ interface CreateRunParams {
|
|
|
187
187
|
inputs: KVMap;
|
|
188
188
|
run_type: string;
|
|
189
189
|
id?: string;
|
|
190
|
-
start_time?: number;
|
|
191
|
-
end_time?: number;
|
|
190
|
+
start_time?: number | string;
|
|
191
|
+
end_time?: number | string;
|
|
192
192
|
extra?: KVMap;
|
|
193
193
|
error?: string;
|
|
194
194
|
serialized?: object;
|
|
@@ -77,20 +77,20 @@ class LangSmithOTLPTraceExporter extends exporter_trace_otlp_proto_1.OTLPTraceEx
|
|
|
77
77
|
const defaultBaseUrl = defaultLsEndpoint.replace(/\/$/, "");
|
|
78
78
|
const defaultUrl = `${defaultBaseUrl}/otel/v1/traces`;
|
|
79
79
|
// Configure headers with API key and project if available
|
|
80
|
-
let
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
defaultHeaderString += `,Langsmith-Project=${project}`;
|
|
80
|
+
let headers = config?.headers;
|
|
81
|
+
if (headers === undefined) {
|
|
82
|
+
let defaultHeaderString = (0, env_js_2.getEnvironmentVariable)("OTEL_EXPORTER_OTLP_HEADERS") ?? "";
|
|
83
|
+
if (!defaultHeaderString) {
|
|
84
|
+
const apiKey = config?.apiKey ?? (0, env_js_2.getLangSmithEnvironmentVariable)("API_KEY");
|
|
85
|
+
if (apiKey) {
|
|
86
|
+
defaultHeaderString = `x-api-key=${apiKey}`;
|
|
87
|
+
}
|
|
89
88
|
}
|
|
89
|
+
headers = parseHeadersString(defaultHeaderString);
|
|
90
90
|
}
|
|
91
91
|
super({
|
|
92
92
|
url: defaultUrl,
|
|
93
|
-
headers
|
|
93
|
+
headers,
|
|
94
94
|
...config,
|
|
95
95
|
});
|
|
96
96
|
Object.defineProperty(this, "transformExportedSpan", {
|
|
@@ -99,7 +99,15 @@ class LangSmithOTLPTraceExporter extends exporter_trace_otlp_proto_1.OTLPTraceEx
|
|
|
99
99
|
writable: true,
|
|
100
100
|
value: void 0
|
|
101
101
|
});
|
|
102
|
+
Object.defineProperty(this, "projectName", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
configurable: true,
|
|
105
|
+
writable: true,
|
|
106
|
+
value: void 0
|
|
107
|
+
});
|
|
102
108
|
this.transformExportedSpan = config?.transformExportedSpan;
|
|
109
|
+
this.projectName =
|
|
110
|
+
config?.projectName ?? (0, env_js_2.getLangSmithEnvironmentVariable)("PROJECT");
|
|
103
111
|
}
|
|
104
112
|
export(spans, resultCallback) {
|
|
105
113
|
if (!(0, env_js_1.isTracingEnabled)()) {
|
|
@@ -193,6 +201,10 @@ class LangSmithOTLPTraceExporter extends exporter_trace_otlp_proto_1.OTLPTraceEx
|
|
|
193
201
|
span.attributes[`${constants.LANGSMITH_METADATA}.ls_run_name`];
|
|
194
202
|
delete span.attributes[`${constants.LANGSMITH_METADATA}.ls_run_name`];
|
|
195
203
|
}
|
|
204
|
+
if (span.attributes[constants.LANGSMITH_SESSION_NAME] === undefined &&
|
|
205
|
+
this.projectName !== undefined) {
|
|
206
|
+
span.attributes[constants.LANGSMITH_SESSION_NAME] = this.projectName;
|
|
207
|
+
}
|
|
196
208
|
}
|
|
197
209
|
super.export(spans, resultCallback);
|
|
198
210
|
};
|
|
@@ -32,6 +32,10 @@ export type LangSmithOTLPTraceExporterConfig = ConstructorParameters<typeof OTLP
|
|
|
32
32
|
* The name of the project to export traces to.
|
|
33
33
|
*/
|
|
34
34
|
projectName?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Default headers to add to exporter requests.
|
|
37
|
+
*/
|
|
38
|
+
headers?: Record<string, string>;
|
|
35
39
|
};
|
|
36
40
|
/**
|
|
37
41
|
* LangSmith OpenTelemetry trace exporter that extends the standard OTLP trace exporter
|
|
@@ -50,6 +54,7 @@ export type LangSmithOTLPTraceExporterConfig = ConstructorParameters<typeof OTLP
|
|
|
50
54
|
*/
|
|
51
55
|
export declare class LangSmithOTLPTraceExporter extends OTLPTraceExporter {
|
|
52
56
|
private transformExportedSpan?;
|
|
57
|
+
private projectName?;
|
|
53
58
|
constructor(config?: LangSmithOTLPTraceExporterConfig);
|
|
54
59
|
export(spans: ReadableSpan[], resultCallback: Parameters<OTLPTraceExporter["export"]>[1]): void;
|
|
55
60
|
}
|
|
@@ -41,20 +41,20 @@ export class LangSmithOTLPTraceExporter extends OTLPTraceExporter {
|
|
|
41
41
|
const defaultBaseUrl = defaultLsEndpoint.replace(/\/$/, "");
|
|
42
42
|
const defaultUrl = `${defaultBaseUrl}/otel/v1/traces`;
|
|
43
43
|
// Configure headers with API key and project if available
|
|
44
|
-
let
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
defaultHeaderString += `,Langsmith-Project=${project}`;
|
|
44
|
+
let headers = config?.headers;
|
|
45
|
+
if (headers === undefined) {
|
|
46
|
+
let defaultHeaderString = getEnvironmentVariable("OTEL_EXPORTER_OTLP_HEADERS") ?? "";
|
|
47
|
+
if (!defaultHeaderString) {
|
|
48
|
+
const apiKey = config?.apiKey ?? getLangSmithEnvironmentVariable("API_KEY");
|
|
49
|
+
if (apiKey) {
|
|
50
|
+
defaultHeaderString = `x-api-key=${apiKey}`;
|
|
51
|
+
}
|
|
53
52
|
}
|
|
53
|
+
headers = parseHeadersString(defaultHeaderString);
|
|
54
54
|
}
|
|
55
55
|
super({
|
|
56
56
|
url: defaultUrl,
|
|
57
|
-
headers
|
|
57
|
+
headers,
|
|
58
58
|
...config,
|
|
59
59
|
});
|
|
60
60
|
Object.defineProperty(this, "transformExportedSpan", {
|
|
@@ -63,7 +63,15 @@ export class LangSmithOTLPTraceExporter extends OTLPTraceExporter {
|
|
|
63
63
|
writable: true,
|
|
64
64
|
value: void 0
|
|
65
65
|
});
|
|
66
|
+
Object.defineProperty(this, "projectName", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
configurable: true,
|
|
69
|
+
writable: true,
|
|
70
|
+
value: void 0
|
|
71
|
+
});
|
|
66
72
|
this.transformExportedSpan = config?.transformExportedSpan;
|
|
73
|
+
this.projectName =
|
|
74
|
+
config?.projectName ?? getLangSmithEnvironmentVariable("PROJECT");
|
|
67
75
|
}
|
|
68
76
|
export(spans, resultCallback) {
|
|
69
77
|
if (!isTracingEnabled()) {
|
|
@@ -157,6 +165,10 @@ export class LangSmithOTLPTraceExporter extends OTLPTraceExporter {
|
|
|
157
165
|
span.attributes[`${constants.LANGSMITH_METADATA}.ls_run_name`];
|
|
158
166
|
delete span.attributes[`${constants.LANGSMITH_METADATA}.ls_run_name`];
|
|
159
167
|
}
|
|
168
|
+
if (span.attributes[constants.LANGSMITH_SESSION_NAME] === undefined &&
|
|
169
|
+
this.projectName !== undefined) {
|
|
170
|
+
span.attributes[constants.LANGSMITH_SESSION_NAME] = this.projectName;
|
|
171
|
+
}
|
|
160
172
|
}
|
|
161
173
|
super.export(spans, resultCallback);
|
|
162
174
|
};
|
|
@@ -102,7 +102,7 @@ class LangSmithToOTELTranslator {
|
|
|
102
102
|
}
|
|
103
103
|
// End the span if end_time is present
|
|
104
104
|
if (runInfo.end_time) {
|
|
105
|
-
span.end(runInfo.end_time);
|
|
105
|
+
span.end(new Date(runInfo.end_time));
|
|
106
106
|
}
|
|
107
107
|
return span;
|
|
108
108
|
}
|
|
@@ -126,7 +126,7 @@ class LangSmithToOTELTranslator {
|
|
|
126
126
|
// End the span if end_time is present
|
|
127
127
|
const endTime = runInfo.end_time;
|
|
128
128
|
if (endTime) {
|
|
129
|
-
span.end(endTime);
|
|
129
|
+
span.end(new Date(endTime));
|
|
130
130
|
this.spans.delete(op.id);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
@@ -66,7 +66,7 @@ export class LangSmithToOTELTranslator {
|
|
|
66
66
|
}
|
|
67
67
|
// End the span if end_time is present
|
|
68
68
|
if (runInfo.end_time) {
|
|
69
|
-
span.end(runInfo.end_time);
|
|
69
|
+
span.end(new Date(runInfo.end_time));
|
|
70
70
|
}
|
|
71
71
|
return span;
|
|
72
72
|
}
|
|
@@ -90,7 +90,7 @@ export class LangSmithToOTELTranslator {
|
|
|
90
90
|
// End the span if end_time is present
|
|
91
91
|
const endTime = runInfo.end_time;
|
|
92
92
|
if (endTime) {
|
|
93
|
-
span.end(endTime);
|
|
93
|
+
span.end(new Date(endTime));
|
|
94
94
|
this.spans.delete(op.id);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -5,7 +5,7 @@ export interface OTELSpan {
|
|
|
5
5
|
message?: string;
|
|
6
6
|
}) => void;
|
|
7
7
|
recordException: (exception: Error | string) => void;
|
|
8
|
-
end: (endTime?: number) => void;
|
|
8
|
+
end: (endTime?: number | Date) => void;
|
|
9
9
|
}
|
|
10
10
|
export interface OTELTracer {
|
|
11
11
|
startSpan: (name: string, options?: any) => OTELSpan;
|
package/dist/index.cjs
CHANGED
|
@@ -10,4 +10,4 @@ Object.defineProperty(exports, "overrideFetchImplementation", { enumerable: true
|
|
|
10
10
|
var project_js_1 = require("./utils/project.cjs");
|
|
11
11
|
Object.defineProperty(exports, "getDefaultProjectName", { enumerable: true, get: function () { return project_js_1.getDefaultProjectName; } });
|
|
12
12
|
// Update using yarn bump-version
|
|
13
|
-
exports.__version__ = "0.3.
|
|
13
|
+
exports.__version__ = "0.3.46-rc.0";
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export type { Dataset, Example, TracerSession, Run, Feedback, RetrieverOutput, }
|
|
|
3
3
|
export { RunTree, type RunTreeConfig } from "./run_trees.js";
|
|
4
4
|
export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
5
5
|
export { getDefaultProjectName } from "./utils/project.js";
|
|
6
|
-
export declare const __version__ = "0.3.
|
|
6
|
+
export declare const __version__ = "0.3.46-rc.0";
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,4 @@ export { RunTree } from "./run_trees.js";
|
|
|
3
3
|
export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
4
4
|
export { getDefaultProjectName } from "./utils/project.js";
|
|
5
5
|
// Update using yarn bump-version
|
|
6
|
-
export const __version__ = "0.3.
|
|
6
|
+
export const __version__ = "0.3.46-rc.0";
|
package/dist/run_trees.cjs
CHANGED
|
@@ -53,7 +53,13 @@ function convertToDottedOrderFormat(epoch, runId, executionOrder = 1) {
|
|
|
53
53
|
// Date only has millisecond precision, so we use the microseconds to break
|
|
54
54
|
// possible ties, avoiding incorrect run order
|
|
55
55
|
const paddedOrder = executionOrder.toFixed(0).slice(0, 3).padStart(3, "0");
|
|
56
|
-
|
|
56
|
+
const microsecondPrecisionDatestring = `${new Date(epoch)
|
|
57
|
+
.toISOString()
|
|
58
|
+
.slice(0, -1)}${paddedOrder}Z`;
|
|
59
|
+
return {
|
|
60
|
+
dottedOrder: stripNonAlphanumeric(microsecondPrecisionDatestring) + runId,
|
|
61
|
+
microsecondPrecisionDatestring,
|
|
62
|
+
};
|
|
57
63
|
}
|
|
58
64
|
/**
|
|
59
65
|
* Baggage header information
|
|
@@ -159,6 +165,12 @@ class RunTree {
|
|
|
159
165
|
writable: true,
|
|
160
166
|
value: void 0
|
|
161
167
|
});
|
|
168
|
+
Object.defineProperty(this, "parent_run_id", {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
configurable: true,
|
|
171
|
+
writable: true,
|
|
172
|
+
value: void 0
|
|
173
|
+
});
|
|
162
174
|
Object.defineProperty(this, "child_runs", {
|
|
163
175
|
enumerable: true,
|
|
164
176
|
configurable: true,
|
|
@@ -280,6 +292,12 @@ class RunTree {
|
|
|
280
292
|
writable: true,
|
|
281
293
|
value: void 0
|
|
282
294
|
});
|
|
295
|
+
Object.defineProperty(this, "_serialized_start_time", {
|
|
296
|
+
enumerable: true,
|
|
297
|
+
configurable: true,
|
|
298
|
+
writable: true,
|
|
299
|
+
value: void 0
|
|
300
|
+
});
|
|
283
301
|
// If you pass in a run tree directly, return a shallow clone
|
|
284
302
|
if (isRunTree(originalConfig)) {
|
|
285
303
|
Object.assign(this, { ...originalConfig });
|
|
@@ -306,14 +324,14 @@ class RunTree {
|
|
|
306
324
|
this.execution_order ??= 1;
|
|
307
325
|
this.child_execution_order ??= 1;
|
|
308
326
|
if (!this.dotted_order) {
|
|
309
|
-
const
|
|
327
|
+
const { dottedOrder, microsecondPrecisionDatestring } = convertToDottedOrderFormat(this.start_time, this.id, this.execution_order);
|
|
310
328
|
if (this.parent_run) {
|
|
311
|
-
this.dotted_order =
|
|
312
|
-
this.parent_run.dotted_order + "." + currentDottedOrder;
|
|
329
|
+
this.dotted_order = this.parent_run.dotted_order + "." + dottedOrder;
|
|
313
330
|
}
|
|
314
331
|
else {
|
|
315
|
-
this.dotted_order =
|
|
332
|
+
this.dotted_order = dottedOrder;
|
|
316
333
|
}
|
|
334
|
+
this._serialized_start_time = microsecondPrecisionDatestring;
|
|
317
335
|
}
|
|
318
336
|
}
|
|
319
337
|
set metadata(metadata) {
|
|
@@ -430,13 +448,13 @@ class RunTree {
|
|
|
430
448
|
parent_run_id = undefined;
|
|
431
449
|
}
|
|
432
450
|
else {
|
|
433
|
-
parent_run_id = run.parent_run?.id;
|
|
451
|
+
parent_run_id = run.parent_run_id ?? run.parent_run?.id;
|
|
434
452
|
child_runs = [];
|
|
435
453
|
}
|
|
436
454
|
return {
|
|
437
455
|
id: run.id,
|
|
438
456
|
name: run.name,
|
|
439
|
-
start_time: run.start_time,
|
|
457
|
+
start_time: run._serialized_start_time ?? run.start_time,
|
|
440
458
|
end_time: run.end_time,
|
|
441
459
|
run_type: run.run_type,
|
|
442
460
|
reference_example_id: run.reference_example_id,
|
package/dist/run_trees.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Client } from "./client.js";
|
|
2
2
|
import { Attachments, BaseRun, KVMap, RunCreate } from "./schemas.js";
|
|
3
|
-
export declare function convertToDottedOrderFormat(epoch: number, runId: string, executionOrder?: number):
|
|
3
|
+
export declare function convertToDottedOrderFormat(epoch: number, runId: string, executionOrder?: number): {
|
|
4
|
+
dottedOrder: string;
|
|
5
|
+
microsecondPrecisionDatestring: string;
|
|
6
|
+
};
|
|
4
7
|
export interface RunTreeConfig {
|
|
5
8
|
name: string;
|
|
6
9
|
run_type?: string;
|
|
@@ -9,8 +12,8 @@ export interface RunTreeConfig {
|
|
|
9
12
|
parent_run?: RunTree;
|
|
10
13
|
parent_run_id?: string;
|
|
11
14
|
child_runs?: RunTree[];
|
|
12
|
-
start_time?: number;
|
|
13
|
-
end_time?: number;
|
|
15
|
+
start_time?: number | string;
|
|
16
|
+
end_time?: number | string;
|
|
14
17
|
extra?: KVMap;
|
|
15
18
|
metadata?: KVMap;
|
|
16
19
|
tags?: string[];
|
|
@@ -66,6 +69,7 @@ export declare class RunTree implements BaseRun {
|
|
|
66
69
|
run_type: string;
|
|
67
70
|
project_name: string;
|
|
68
71
|
parent_run?: RunTree;
|
|
72
|
+
parent_run_id?: string;
|
|
69
73
|
child_runs: RunTree[];
|
|
70
74
|
start_time: number;
|
|
71
75
|
end_time?: number;
|
|
@@ -92,6 +96,7 @@ export declare class RunTree implements BaseRun {
|
|
|
92
96
|
* Projects to replicate this run to with optional updates.
|
|
93
97
|
*/
|
|
94
98
|
replicas?: WriteReplica[];
|
|
99
|
+
private _serialized_start_time;
|
|
95
100
|
constructor(originalConfig: RunTreeConfig | RunTree);
|
|
96
101
|
set metadata(metadata: KVMap);
|
|
97
102
|
get metadata(): KVMap;
|
package/dist/run_trees.js
CHANGED
|
@@ -14,7 +14,13 @@ export function convertToDottedOrderFormat(epoch, runId, executionOrder = 1) {
|
|
|
14
14
|
// Date only has millisecond precision, so we use the microseconds to break
|
|
15
15
|
// possible ties, avoiding incorrect run order
|
|
16
16
|
const paddedOrder = executionOrder.toFixed(0).slice(0, 3).padStart(3, "0");
|
|
17
|
-
|
|
17
|
+
const microsecondPrecisionDatestring = `${new Date(epoch)
|
|
18
|
+
.toISOString()
|
|
19
|
+
.slice(0, -1)}${paddedOrder}Z`;
|
|
20
|
+
return {
|
|
21
|
+
dottedOrder: stripNonAlphanumeric(microsecondPrecisionDatestring) + runId,
|
|
22
|
+
microsecondPrecisionDatestring,
|
|
23
|
+
};
|
|
18
24
|
}
|
|
19
25
|
/**
|
|
20
26
|
* Baggage header information
|
|
@@ -120,6 +126,12 @@ export class RunTree {
|
|
|
120
126
|
writable: true,
|
|
121
127
|
value: void 0
|
|
122
128
|
});
|
|
129
|
+
Object.defineProperty(this, "parent_run_id", {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
configurable: true,
|
|
132
|
+
writable: true,
|
|
133
|
+
value: void 0
|
|
134
|
+
});
|
|
123
135
|
Object.defineProperty(this, "child_runs", {
|
|
124
136
|
enumerable: true,
|
|
125
137
|
configurable: true,
|
|
@@ -241,6 +253,12 @@ export class RunTree {
|
|
|
241
253
|
writable: true,
|
|
242
254
|
value: void 0
|
|
243
255
|
});
|
|
256
|
+
Object.defineProperty(this, "_serialized_start_time", {
|
|
257
|
+
enumerable: true,
|
|
258
|
+
configurable: true,
|
|
259
|
+
writable: true,
|
|
260
|
+
value: void 0
|
|
261
|
+
});
|
|
244
262
|
// If you pass in a run tree directly, return a shallow clone
|
|
245
263
|
if (isRunTree(originalConfig)) {
|
|
246
264
|
Object.assign(this, { ...originalConfig });
|
|
@@ -267,14 +285,14 @@ export class RunTree {
|
|
|
267
285
|
this.execution_order ??= 1;
|
|
268
286
|
this.child_execution_order ??= 1;
|
|
269
287
|
if (!this.dotted_order) {
|
|
270
|
-
const
|
|
288
|
+
const { dottedOrder, microsecondPrecisionDatestring } = convertToDottedOrderFormat(this.start_time, this.id, this.execution_order);
|
|
271
289
|
if (this.parent_run) {
|
|
272
|
-
this.dotted_order =
|
|
273
|
-
this.parent_run.dotted_order + "." + currentDottedOrder;
|
|
290
|
+
this.dotted_order = this.parent_run.dotted_order + "." + dottedOrder;
|
|
274
291
|
}
|
|
275
292
|
else {
|
|
276
|
-
this.dotted_order =
|
|
293
|
+
this.dotted_order = dottedOrder;
|
|
277
294
|
}
|
|
295
|
+
this._serialized_start_time = microsecondPrecisionDatestring;
|
|
278
296
|
}
|
|
279
297
|
}
|
|
280
298
|
set metadata(metadata) {
|
|
@@ -391,13 +409,13 @@ export class RunTree {
|
|
|
391
409
|
parent_run_id = undefined;
|
|
392
410
|
}
|
|
393
411
|
else {
|
|
394
|
-
parent_run_id = run.parent_run?.id;
|
|
412
|
+
parent_run_id = run.parent_run_id ?? run.parent_run?.id;
|
|
395
413
|
child_runs = [];
|
|
396
414
|
}
|
|
397
415
|
return {
|
|
398
416
|
id: run.id,
|
|
399
417
|
name: run.name,
|
|
400
|
-
start_time: run.start_time,
|
|
418
|
+
start_time: run._serialized_start_time ?? run.start_time,
|
|
401
419
|
end_time: run.end_time,
|
|
402
420
|
run_type: run.run_type,
|
|
403
421
|
reference_example_id: run.reference_example_id,
|
package/dist/schemas.d.ts
CHANGED
|
@@ -55,11 +55,11 @@ export interface BaseRun {
|
|
|
55
55
|
/** A human-readable name for the run. */
|
|
56
56
|
name: string;
|
|
57
57
|
/** The epoch time at which the run started, if available. */
|
|
58
|
-
start_time?: number;
|
|
58
|
+
start_time?: number | string;
|
|
59
59
|
/** Specifies the type of run (tool, chain, llm, etc.). */
|
|
60
60
|
run_type: string;
|
|
61
61
|
/** The epoch time at which the run ended, if applicable. */
|
|
62
|
-
end_time?: number;
|
|
62
|
+
end_time?: number | string;
|
|
63
63
|
/** Any additional metadata or settings for the run. */
|
|
64
64
|
extra?: KVMap;
|
|
65
65
|
/** Error message, captured if the run faces any issues. */
|
|
@@ -152,7 +152,7 @@ export interface RunCreate extends BaseRun {
|
|
|
152
152
|
}
|
|
153
153
|
export interface RunUpdate {
|
|
154
154
|
id?: string;
|
|
155
|
-
end_time?: number;
|
|
155
|
+
end_time?: number | string;
|
|
156
156
|
extra?: KVMap;
|
|
157
157
|
tags?: string[];
|
|
158
158
|
error?: string;
|
package/dist/traceable.cjs
CHANGED
|
@@ -17,7 +17,7 @@ traceable_js_1.AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new n
|
|
|
17
17
|
/**
|
|
18
18
|
* Create OpenTelemetry context manager from RunTree if OTEL is enabled.
|
|
19
19
|
*/
|
|
20
|
-
function maybeCreateOtelContext(runTree, tracer
|
|
20
|
+
function maybeCreateOtelContext(runTree, projectName, tracer
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
22
|
) {
|
|
23
23
|
if (!runTree || (0, env_js_2.getEnvironmentVariable)("OTEL_ENABLED") !== "true") {
|
|
@@ -34,6 +34,9 @@ function maybeCreateOtelContext(runTree, tracer
|
|
|
34
34
|
attributes[constants_js_2.LANGSMITH_REFERENCE_EXAMPLE_ID] =
|
|
35
35
|
runTree.reference_example_id;
|
|
36
36
|
}
|
|
37
|
+
if (projectName !== undefined) {
|
|
38
|
+
attributes[constants_js_2.LANGSMITH_SESSION_NAME] = projectName;
|
|
39
|
+
}
|
|
37
40
|
const forceOTELRoot = runTree.extra?.ls_otel_root === true;
|
|
38
41
|
return resolvedTracer.startActiveSpan(runTree.name, {
|
|
39
42
|
attributes,
|
|
@@ -439,7 +442,7 @@ function traceable(wrappedFunc, config) {
|
|
|
439
442
|
const currentRunTree = (0, run_trees_js_1.isRunTree)(currentContext)
|
|
440
443
|
? currentContext
|
|
441
444
|
: undefined;
|
|
442
|
-
const otelContextManager = maybeCreateOtelContext(currentRunTree, config?.tracer);
|
|
445
|
+
const otelContextManager = maybeCreateOtelContext(currentRunTree, config?.project_name, config?.tracer);
|
|
443
446
|
const otel_context = (0, otel_js_1.getOTELContext)();
|
|
444
447
|
const runWithContext = () => {
|
|
445
448
|
const postRunPromise = currentRunTree?.postRun();
|
package/dist/traceable.js
CHANGED
|
@@ -8,12 +8,12 @@ import { getEnvironmentVariable } from "./utils/env.js";
|
|
|
8
8
|
import { __version__ } from "./index.js";
|
|
9
9
|
import { getOTELTrace, getOTELContext } from "./singletons/otel.js";
|
|
10
10
|
import { getUuidFromOtelSpanId } from "./experimental/otel/utils.js";
|
|
11
|
-
import { LANGSMITH_REFERENCE_EXAMPLE_ID } from "./experimental/otel/constants.js";
|
|
11
|
+
import { LANGSMITH_REFERENCE_EXAMPLE_ID, LANGSMITH_SESSION_NAME, } from "./experimental/otel/constants.js";
|
|
12
12
|
AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new AsyncLocalStorage());
|
|
13
13
|
/**
|
|
14
14
|
* Create OpenTelemetry context manager from RunTree if OTEL is enabled.
|
|
15
15
|
*/
|
|
16
|
-
function maybeCreateOtelContext(runTree, tracer
|
|
16
|
+
function maybeCreateOtelContext(runTree, projectName, tracer
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
18
|
) {
|
|
19
19
|
if (!runTree || getEnvironmentVariable("OTEL_ENABLED") !== "true") {
|
|
@@ -30,6 +30,9 @@ function maybeCreateOtelContext(runTree, tracer
|
|
|
30
30
|
attributes[LANGSMITH_REFERENCE_EXAMPLE_ID] =
|
|
31
31
|
runTree.reference_example_id;
|
|
32
32
|
}
|
|
33
|
+
if (projectName !== undefined) {
|
|
34
|
+
attributes[LANGSMITH_SESSION_NAME] = projectName;
|
|
35
|
+
}
|
|
33
36
|
const forceOTELRoot = runTree.extra?.ls_otel_root === true;
|
|
34
37
|
return resolvedTracer.startActiveSpan(runTree.name, {
|
|
35
38
|
attributes,
|
|
@@ -435,7 +438,7 @@ export function traceable(wrappedFunc, config) {
|
|
|
435
438
|
const currentRunTree = isRunTree(currentContext)
|
|
436
439
|
? currentContext
|
|
437
440
|
: undefined;
|
|
438
|
-
const otelContextManager = maybeCreateOtelContext(currentRunTree, config?.tracer);
|
|
441
|
+
const otelContextManager = maybeCreateOtelContext(currentRunTree, config?.project_name, config?.tracer);
|
|
439
442
|
const otel_context = getOTELContext();
|
|
440
443
|
const runWithContext = () => {
|
|
441
444
|
const postRunPromise = currentRunTree?.postRun();
|
|
@@ -385,7 +385,7 @@ function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
|
|
|
385
385
|
context.enableTestTracking = lsParams.config.enableTestTracking;
|
|
386
386
|
}
|
|
387
387
|
const { config, inputs, referenceOutputs, ...rest } = lsParams;
|
|
388
|
-
const totalRuns = config?.iterations ?? 1;
|
|
388
|
+
const totalRuns = config?.repetitions ?? config?.iterations ?? 1;
|
|
389
389
|
for (let i = 0; i < totalRuns; i += 1) {
|
|
390
390
|
const testUuid = (0, uuid_1.v4)().replace(/-/g, "").slice(0, 13);
|
|
391
391
|
// Jest will not group tests under the same "describe" group if you await the test and
|
|
@@ -338,7 +338,7 @@ export function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
|
|
|
338
338
|
context.enableTestTracking = lsParams.config.enableTestTracking;
|
|
339
339
|
}
|
|
340
340
|
const { config, inputs, referenceOutputs, ...rest } = lsParams;
|
|
341
|
-
const totalRuns = config?.iterations ?? 1;
|
|
341
|
+
const totalRuns = config?.repetitions ?? config?.iterations ?? 1;
|
|
342
342
|
for (let i = 0; i < totalRuns; i += 1) {
|
|
343
343
|
const testUuid = v4().replace(/-/g, "").slice(0, 13);
|
|
344
344
|
// Jest will not group tests under the same "describe" group if you await the test and
|
|
@@ -5,7 +5,9 @@ import type { RunTreeConfig } from "../../run_trees.js";
|
|
|
5
5
|
import type { SimpleEvaluator } from "./vendor/evaluatedBy.js";
|
|
6
6
|
export { type SimpleEvaluator };
|
|
7
7
|
export type LangSmithJestlikeWrapperConfig = Partial<Omit<RunTreeConfig, "client">> & {
|
|
8
|
+
/** @deprecated Use `repetitions` instead. */
|
|
8
9
|
iterations?: number;
|
|
10
|
+
repetitions?: number;
|
|
9
11
|
enableTestTracking?: boolean;
|
|
10
12
|
};
|
|
11
13
|
export type LangSmithJestlikeWrapperParams<I, O> = {
|