langsmith 0.3.35-rc.3 → 0.3.35-rc.4
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/experimental/otel/exporter.cjs +2 -2
- package/dist/experimental/otel/exporter.d.ts +1 -1
- package/dist/experimental/otel/exporter.js +1 -1
- package/dist/experimental/otel/setup.cjs +36 -28
- package/dist/experimental/otel/setup.d.ts +8 -2
- package/dist/experimental/otel/setup.js +36 -28
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
|
@@ -34,10 +34,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.LangSmithOTLPTraceExporter = void 0;
|
|
37
|
-
const
|
|
37
|
+
const exporter_trace_otlp_proto_1 = require("@opentelemetry/exporter-trace-otlp-proto");
|
|
38
38
|
const constants = __importStar(require("./constants.cjs"));
|
|
39
39
|
const env_js_1 = require("../../env.cjs");
|
|
40
|
-
class LangSmithOTLPTraceExporter extends
|
|
40
|
+
class LangSmithOTLPTraceExporter extends exporter_trace_otlp_proto_1.OTLPTraceExporter {
|
|
41
41
|
export(spans, resultCallback) {
|
|
42
42
|
if (!(0, env_js_1.isTracingEnabled)()) {
|
|
43
43
|
return resultCallback({ code: 0 });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-
|
|
1
|
+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
|
|
2
2
|
import { ReadableSpan } from "@opentelemetry/sdk-trace-base";
|
|
3
3
|
export declare class LangSmithOTLPTraceExporter extends OTLPTraceExporter {
|
|
4
4
|
export(spans: ReadableSpan[], resultCallback: Parameters<OTLPTraceExporter["export"]>[1]): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-
|
|
1
|
+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
|
|
2
2
|
import * as constants from "./constants.js";
|
|
3
3
|
import { isTracingEnabled } from "../../env.js";
|
|
4
4
|
export class LangSmithOTLPTraceExporter extends OTLPTraceExporter {
|
|
@@ -25,7 +25,7 @@ function parseHeadersString(headersStr) {
|
|
|
25
25
|
});
|
|
26
26
|
return headers;
|
|
27
27
|
}
|
|
28
|
-
const initializeOTEL = ({ globalTracerProvider }) => {
|
|
28
|
+
const initializeOTEL = ({ globalTracerProvider, }) => {
|
|
29
29
|
const otel = {
|
|
30
30
|
trace: api_1.trace,
|
|
31
31
|
context: api_1.context,
|
|
@@ -34,34 +34,34 @@ const initializeOTEL = ({ globalTracerProvider }) => {
|
|
|
34
34
|
const contextManager = new context_async_hooks_1.AsyncHooksContextManager();
|
|
35
35
|
contextManager.enable();
|
|
36
36
|
api_1.context.setGlobalContextManager(contextManager);
|
|
37
|
-
if
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
// Set LangSmith-specific defaults if not already set in environment
|
|
38
|
+
if (!(0, env_js_1.getEnvironmentVariable)("OTEL_EXPORTER_OTLP_ENDPOINT")) {
|
|
39
|
+
const lsEndpoint = (0, env_js_1.getLangSmithEnvironmentVariable)("ENDPOINT") ||
|
|
40
|
+
"https://api.smith.langchain.com";
|
|
41
|
+
const baseUrl = lsEndpoint.replace(/\/$/, "");
|
|
42
|
+
(0, env_js_1.setEnvironmentVariable)("OTEL_EXPORTER_OTLP_ENDPOINT", `${baseUrl}/otel/v1/traces`);
|
|
43
|
+
}
|
|
44
|
+
// Configure headers with API key and project if available
|
|
45
|
+
if (!(0, env_js_1.getEnvironmentVariable)("OTEL_EXPORTER_OTLP_HEADERS")) {
|
|
46
|
+
const apiKey = (0, env_js_1.getLangSmithEnvironmentVariable)("API_KEY");
|
|
47
|
+
if (!apiKey) {
|
|
48
|
+
throw new Error("LANGSMITH_API_KEY or LANGCHAIN_API_KEY environment variable is required");
|
|
44
49
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
throw new Error("LANGSMITH_API_KEY or LANGCHAIN_API_KEY environment variable is required");
|
|
50
|
-
}
|
|
51
|
-
let headers = `x-api-key=${apiKey}`;
|
|
52
|
-
const project = (0, env_js_1.getLangSmithEnvironmentVariable)("PROJECT");
|
|
53
|
-
if (project) {
|
|
54
|
-
headers += `,Langsmith-Project=${project}`;
|
|
55
|
-
}
|
|
56
|
-
(0, env_js_1.setEnvironmentVariable)("OTEL_EXPORTER_OTLP_HEADERS", headers);
|
|
50
|
+
let headers = `x-api-key=${apiKey}`;
|
|
51
|
+
const project = (0, env_js_1.getLangSmithEnvironmentVariable)("PROJECT");
|
|
52
|
+
if (project) {
|
|
53
|
+
headers += `,Langsmith-Project=${project}`;
|
|
57
54
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
(0, env_js_1.setEnvironmentVariable)("OTEL_EXPORTER_OTLP_HEADERS", headers);
|
|
56
|
+
}
|
|
57
|
+
const headersStr = (0, env_js_1.getEnvironmentVariable)("OTEL_EXPORTER_OTLP_HEADERS") || "";
|
|
58
|
+
const headersObj = parseHeadersString(headersStr);
|
|
59
|
+
const DEFAULT_LANGSMITH_SPAN_EXPORTER = new exporter_js_1.LangSmithOTLPTraceExporter({
|
|
60
|
+
url: (0, env_js_1.getEnvironmentVariable)("OTEL_EXPORTER_OTLP_ENDPOINT"),
|
|
61
|
+
headers: headersObj,
|
|
62
|
+
});
|
|
63
|
+
const DEFAULT_LANGSMITH_SPAN_PROCESSOR = new sdk_trace_base_1.BatchSpanProcessor(DEFAULT_LANGSMITH_SPAN_EXPORTER);
|
|
64
|
+
if (!globalTracerProvider) {
|
|
65
65
|
const DEFAULT_LANGSMITH_TRACER_PROVIDER = new sdk_trace_base_1.BasicTracerProvider({
|
|
66
66
|
spanProcessors: [DEFAULT_LANGSMITH_SPAN_PROCESSOR],
|
|
67
67
|
});
|
|
@@ -77,6 +77,14 @@ const initializeOTEL = ({ globalTracerProvider }) => {
|
|
|
77
77
|
}
|
|
78
78
|
return defaultComponents;
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
else {
|
|
81
|
+
const defaultComponents = {
|
|
82
|
+
DEFAULT_LANGSMITH_TRACER_PROVIDER: globalTracerProvider,
|
|
83
|
+
DEFAULT_LANGSMITH_SPAN_PROCESSOR,
|
|
84
|
+
DEFAULT_LANGSMITH_SPAN_EXPORTER,
|
|
85
|
+
};
|
|
86
|
+
(0, otel_js_1.setDefaultOTLPTracerComponents)(defaultComponents);
|
|
87
|
+
return defaultComponents;
|
|
88
|
+
}
|
|
81
89
|
};
|
|
82
90
|
exports.initializeOTEL = initializeOTEL;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { TracerProvider } from "@opentelemetry/api";
|
|
2
|
-
|
|
2
|
+
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
3
|
+
import { LangSmithOTLPTraceExporter } from "./exporter.js";
|
|
4
|
+
declare const initializeOTEL: ({ globalTracerProvider, }: {
|
|
3
5
|
globalTracerProvider?: TracerProvider;
|
|
4
|
-
}) => {
|
|
6
|
+
}) => {
|
|
7
|
+
DEFAULT_LANGSMITH_TRACER_PROVIDER: TracerProvider;
|
|
8
|
+
DEFAULT_LANGSMITH_SPAN_PROCESSOR: BatchSpanProcessor;
|
|
9
|
+
DEFAULT_LANGSMITH_SPAN_EXPORTER: LangSmithOTLPTraceExporter;
|
|
10
|
+
};
|
|
5
11
|
export { initializeOTEL };
|
|
@@ -22,7 +22,7 @@ function parseHeadersString(headersStr) {
|
|
|
22
22
|
});
|
|
23
23
|
return headers;
|
|
24
24
|
}
|
|
25
|
-
const initializeOTEL = ({ globalTracerProvider }) => {
|
|
25
|
+
const initializeOTEL = ({ globalTracerProvider, }) => {
|
|
26
26
|
const otel = {
|
|
27
27
|
trace: otel_trace,
|
|
28
28
|
context: otel_context,
|
|
@@ -31,34 +31,34 @@ const initializeOTEL = ({ globalTracerProvider }) => {
|
|
|
31
31
|
const contextManager = new AsyncHooksContextManager();
|
|
32
32
|
contextManager.enable();
|
|
33
33
|
otel_context.setGlobalContextManager(contextManager);
|
|
34
|
-
if
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
// Set LangSmith-specific defaults if not already set in environment
|
|
35
|
+
if (!getEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT")) {
|
|
36
|
+
const lsEndpoint = getLangSmithEnvironmentVariable("ENDPOINT") ||
|
|
37
|
+
"https://api.smith.langchain.com";
|
|
38
|
+
const baseUrl = lsEndpoint.replace(/\/$/, "");
|
|
39
|
+
setEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT", `${baseUrl}/otel/v1/traces`);
|
|
40
|
+
}
|
|
41
|
+
// Configure headers with API key and project if available
|
|
42
|
+
if (!getEnvironmentVariable("OTEL_EXPORTER_OTLP_HEADERS")) {
|
|
43
|
+
const apiKey = getLangSmithEnvironmentVariable("API_KEY");
|
|
44
|
+
if (!apiKey) {
|
|
45
|
+
throw new Error("LANGSMITH_API_KEY or LANGCHAIN_API_KEY environment variable is required");
|
|
41
46
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
throw new Error("LANGSMITH_API_KEY or LANGCHAIN_API_KEY environment variable is required");
|
|
47
|
-
}
|
|
48
|
-
let headers = `x-api-key=${apiKey}`;
|
|
49
|
-
const project = getLangSmithEnvironmentVariable("PROJECT");
|
|
50
|
-
if (project) {
|
|
51
|
-
headers += `,Langsmith-Project=${project}`;
|
|
52
|
-
}
|
|
53
|
-
setEnvironmentVariable("OTEL_EXPORTER_OTLP_HEADERS", headers);
|
|
47
|
+
let headers = `x-api-key=${apiKey}`;
|
|
48
|
+
const project = getLangSmithEnvironmentVariable("PROJECT");
|
|
49
|
+
if (project) {
|
|
50
|
+
headers += `,Langsmith-Project=${project}`;
|
|
54
51
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
setEnvironmentVariable("OTEL_EXPORTER_OTLP_HEADERS", headers);
|
|
53
|
+
}
|
|
54
|
+
const headersStr = getEnvironmentVariable("OTEL_EXPORTER_OTLP_HEADERS") || "";
|
|
55
|
+
const headersObj = parseHeadersString(headersStr);
|
|
56
|
+
const DEFAULT_LANGSMITH_SPAN_EXPORTER = new LangSmithOTLPTraceExporter({
|
|
57
|
+
url: getEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT"),
|
|
58
|
+
headers: headersObj,
|
|
59
|
+
});
|
|
60
|
+
const DEFAULT_LANGSMITH_SPAN_PROCESSOR = new BatchSpanProcessor(DEFAULT_LANGSMITH_SPAN_EXPORTER);
|
|
61
|
+
if (!globalTracerProvider) {
|
|
62
62
|
const DEFAULT_LANGSMITH_TRACER_PROVIDER = new BasicTracerProvider({
|
|
63
63
|
spanProcessors: [DEFAULT_LANGSMITH_SPAN_PROCESSOR],
|
|
64
64
|
});
|
|
@@ -74,6 +74,14 @@ const initializeOTEL = ({ globalTracerProvider }) => {
|
|
|
74
74
|
}
|
|
75
75
|
return defaultComponents;
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
else {
|
|
78
|
+
const defaultComponents = {
|
|
79
|
+
DEFAULT_LANGSMITH_TRACER_PROVIDER: globalTracerProvider,
|
|
80
|
+
DEFAULT_LANGSMITH_SPAN_PROCESSOR,
|
|
81
|
+
DEFAULT_LANGSMITH_SPAN_EXPORTER,
|
|
82
|
+
};
|
|
83
|
+
setDefaultOTLPTracerComponents(defaultComponents);
|
|
84
|
+
return defaultComponents;
|
|
85
|
+
}
|
|
78
86
|
};
|
|
79
87
|
export { initializeOTEL };
|
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.35-rc.
|
|
13
|
+
exports.__version__ = "0.3.35-rc.4";
|
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.35-rc.
|
|
6
|
+
export declare const __version__ = "0.3.35-rc.4";
|
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.35-rc.
|
|
6
|
+
export const __version__ = "0.3.35-rc.4";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langsmith",
|
|
3
|
-
"version": "0.3.35-rc.
|
|
3
|
+
"version": "0.3.35-rc.4",
|
|
4
4
|
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
|
|
5
5
|
"packageManager": "yarn@1.22.19",
|
|
6
6
|
"files": [
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
"peerDependencies": {
|
|
183
183
|
"openai": "*",
|
|
184
184
|
"@opentelemetry/api": "*",
|
|
185
|
-
"@opentelemetry/exporter-trace-otlp-
|
|
185
|
+
"@opentelemetry/exporter-trace-otlp-proto": "*",
|
|
186
186
|
"@opentelemetry/sdk-trace-base": "*"
|
|
187
187
|
},
|
|
188
188
|
"peerDependenciesMeta": {
|
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
"@opentelemetry/api": {
|
|
193
193
|
"optional": true
|
|
194
194
|
},
|
|
195
|
-
"@opentelemetry/exporter-trace-otlp-
|
|
195
|
+
"@opentelemetry/exporter-trace-otlp-proto": {
|
|
196
196
|
"optional": true
|
|
197
197
|
},
|
|
198
198
|
"@opentelemetry/sdk-trace-base": {
|