pi-langfuse 1.4.8 → 1.5.1
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/package.json +1 -1
- package/src/langfuse.ts +9 -3
package/package.json
CHANGED
package/src/langfuse.ts
CHANGED
|
@@ -57,6 +57,12 @@ function delay(ms: number) {
|
|
|
57
57
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
function debugLog(message: string) {
|
|
61
|
+
if (process.env.PI_LANGFUSE_DEBUG === "1" || process.env.PI_LANGFUSE_DEBUG === "true") {
|
|
62
|
+
console.log(message);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
60
66
|
async function withTimeout<T>(label: string, operation: Promise<T> | undefined): Promise<T | undefined> {
|
|
61
67
|
if (!operation) {
|
|
62
68
|
return undefined;
|
|
@@ -68,7 +74,7 @@ async function withTimeout<T>(label: string, operation: Promise<T> | undefined):
|
|
|
68
74
|
operation,
|
|
69
75
|
new Promise<undefined>((resolve) => {
|
|
70
76
|
timeout = setTimeout(() => {
|
|
71
|
-
|
|
77
|
+
debugLog(`📊 Langfuse: ${label} timed out after ${shutdownStepTimeoutMs}ms`);
|
|
72
78
|
resolve(undefined);
|
|
73
79
|
}, shutdownStepTimeoutMs);
|
|
74
80
|
}),
|
|
@@ -303,7 +309,7 @@ async function fallbackToRestIngestion(rt: LangfuseRuntime) {
|
|
|
303
309
|
|
|
304
310
|
const ingestionApi = rt.scoreClient.api?.ingestion;
|
|
305
311
|
if (!ingestionApi?.batch) {
|
|
306
|
-
|
|
312
|
+
debugLog("📊 Langfuse: REST fallback ingestion is unavailable");
|
|
307
313
|
return;
|
|
308
314
|
}
|
|
309
315
|
|
|
@@ -328,7 +334,7 @@ async function fallbackToRestIngestion(rt: LangfuseRuntime) {
|
|
|
328
334
|
if (errors.length > 0) {
|
|
329
335
|
console.warn("📊 Langfuse: REST fallback ingestion reported errors", errors);
|
|
330
336
|
} else {
|
|
331
|
-
|
|
337
|
+
debugLog(`📊 Langfuse: OTel trace ${trace.id} was not visible; wrote fallback trace via REST ingestion`);
|
|
332
338
|
}
|
|
333
339
|
}
|
|
334
340
|
|