Skip to content

Commit

Permalink
fix(vercel): add more debug logs, fix tracing detection for vercel, b…
Browse files Browse the repository at this point in the history
  • Loading branch information
dqbd authored Nov 5, 2024
2 parents 9e17e05 + 62c7702 commit 21e4486
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "langsmith",
"version": "0.2.4-dev.0",
"version": "0.2.4",
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
"packageManager": "[email protected]",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export { RunTree, type RunTreeConfig } from "./run_trees.js";
export { overrideFetchImplementation } from "./singletons/fetch.js";

// Update using yarn bump-version
export const __version__ = "0.2.4-dev.0";
export const __version__ = "0.2.4";
6 changes: 6 additions & 0 deletions js/src/tests/vercel.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ test("generateText", async () => {
}),
},
experimental_telemetry: AISDKExporter.getSettings({
isEnabled: true,
runId,
functionId: "functionId",
metadata: { userId: "123", language: "english" },
Expand Down Expand Up @@ -86,6 +87,7 @@ test("generateText with image", async () => {
},
],
experimental_telemetry: AISDKExporter.getSettings({
isEnabled: true,
runId,
runName: "vercelImageTest",
functionId: "functionId",
Expand Down Expand Up @@ -125,6 +127,7 @@ test("streamText", async () => {
}),
},
experimental_telemetry: AISDKExporter.getSettings({
isEnabled: true,
runId,
functionId: "functionId",
metadata: { userId: "123", language: "english" },
Expand Down Expand Up @@ -152,6 +155,7 @@ test("generateObject", async () => {
}),
prompt: "What's the weather in Prague?",
experimental_telemetry: AISDKExporter.getSettings({
isEnabled: true,
runId,
functionId: "functionId",
metadata: { userId: "123", language: "english" },
Expand All @@ -177,6 +181,7 @@ test("streamObject", async () => {
}),
prompt: "What's the weather in Prague?",
experimental_telemetry: AISDKExporter.getSettings({
isEnabled: true,
runId,
functionId: "functionId",
metadata: {
Expand Down Expand Up @@ -217,6 +222,7 @@ test("traceable", async () => {
}),
},
experimental_telemetry: AISDKExporter.getSettings({
isEnabled: true,
functionId: "functionId",
runName: "nestedVercelTrace",
metadata: { userId: "123", language: "english" },
Expand Down
5 changes: 5 additions & 0 deletions js/src/tests/vercel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ test("generateText", async () => {
}),
},
experimental_telemetry: AISDKExporter.getSettings({
isEnabled: true,
runName: "generateText",
functionId: "functionId",
metadata: { userId: "123", language: "english" },
Expand Down Expand Up @@ -354,6 +355,7 @@ test("streamText", async () => {
}),
},
experimental_telemetry: AISDKExporter.getSettings({
isEnabled: true,
functionId: "functionId",
metadata: { userId: "123", language: "english" },
}),
Expand Down Expand Up @@ -547,6 +549,7 @@ test("generateObject", async () => {
}),
prompt: "What's the weather in Prague?",
experimental_telemetry: AISDKExporter.getSettings({
isEnabled: true,
functionId: "functionId",
metadata: { userId: "123", language: "english" },
}),
Expand Down Expand Up @@ -656,6 +659,7 @@ test("streamObject", async () => {
}),
prompt: "What's the weather in Prague?",
experimental_telemetry: AISDKExporter.getSettings({
isEnabled: true,
functionId: "functionId",
metadata: { userId: "123", language: "english" },
}),
Expand Down Expand Up @@ -755,6 +759,7 @@ test("traceable", async () => {
}),
},
experimental_telemetry: AISDKExporter.getSettings({
isEnabled: true,
runName: "generateText",
functionId: "functionId",
metadata: { userId: "123", language: "english" },
Expand Down
5 changes: 4 additions & 1 deletion js/src/vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getLangSmithEnvironmentVariable,
getEnvironmentVariable,
} from "./utils/env.js";
import { isTracingEnabled } from "./env.js";

// eslint-disable-next-line @typescript-eslint/ban-types
type AnyString = string & {};
Expand Down Expand Up @@ -319,6 +320,8 @@ export class AISDKExporter {
this.client = args?.client ?? new Client();
this.debug =
args?.debug ?? getEnvironmentVariable("OTEL_LOG_LEVEL") === "DEBUG";

this.logDebug("creating exporter", { tracingEnabled: isTracingEnabled() });
}

static getSettings(settings?: TelemetrySettings) {
Expand All @@ -328,7 +331,7 @@ export class AISDKExporter {
if (runName != null) metadata[RUN_NAME_METADATA_KEY.input] = runName;

// attempt to obtain the run tree if used within a traceable function
let defaultEnabled = true;
let defaultEnabled = settings?.isEnabled ?? isTracingEnabled();
try {
const runTree = getCurrentRunTree();
const headers = runTree.toHeaders();
Expand Down

0 comments on commit 21e4486

Please sign in to comment.