@ramarivera/coding-agent-langfuse 0.1.28 → 0.1.29
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/backfill.js +2 -16
- package/package.json +1 -1
package/dist/backfill.js
CHANGED
|
@@ -1203,10 +1203,7 @@ function toOtlp(events, options = {}) {
|
|
|
1203
1203
|
const sortedEvents = [...traceEventsForSession].sort((a, b) => a.startMs - b.startMs);
|
|
1204
1204
|
const traceStartMs = sortedEvents[0]?.startMs ?? Date.now();
|
|
1205
1205
|
const traceEndMs = Math.max(...sortedEvents.map((event) => event.endMs ?? event.startMs + 1), traceStartMs + 1);
|
|
1206
|
-
const
|
|
1207
|
-
const lastOutputEvent = [...sortedEvents]
|
|
1208
|
-
.reverse()
|
|
1209
|
-
.find((event) => event.output !== undefined);
|
|
1206
|
+
const shouldEmitRootSpan = sortedEvents.some((event) => event.recordId === "session");
|
|
1210
1207
|
const rootAttributes = [
|
|
1211
1208
|
attr("service.name", `agent.${first.agent}`),
|
|
1212
1209
|
attr("deployment.environment", "local"),
|
|
@@ -1226,8 +1223,6 @@ function toOtlp(events, options = {}) {
|
|
|
1226
1223
|
attr("langfuse.trace.metadata.machine", currentHost),
|
|
1227
1224
|
attr("langfuse.trace.metadata.source_path", first.sourcePath),
|
|
1228
1225
|
attr("langfuse.trace.metadata.cwd", first.cwd),
|
|
1229
|
-
attr("langfuse.trace.input", firstInputEvent?.input),
|
|
1230
|
-
attr("langfuse.trace.output", lastOutputEvent?.output),
|
|
1231
1226
|
attr("langfuse.observation.metadata.agent", first.agent),
|
|
1232
1227
|
attr("langfuse.observation.metadata.host", currentHost),
|
|
1233
1228
|
attr("langfuse.observation.metadata.machine", currentHost),
|
|
@@ -1286,13 +1281,6 @@ function toOtlp(events, options = {}) {
|
|
|
1286
1281
|
attr("agent.record_id", event.recordId),
|
|
1287
1282
|
attr("agent.original_start_time", new Date(event.startMs).toISOString()),
|
|
1288
1283
|
attr("agent.original_end_time", event.endMs === undefined ? undefined : new Date(event.endMs).toISOString()),
|
|
1289
|
-
attr("langfuse.trace.metadata.agent", event.agent),
|
|
1290
|
-
attr("langfuse.trace.metadata.host", currentHost),
|
|
1291
|
-
attr("langfuse.trace.metadata.machine", currentHost),
|
|
1292
|
-
attr("langfuse.trace.metadata.source_path", event.sourcePath),
|
|
1293
|
-
attr("langfuse.trace.metadata.cwd", event.cwd),
|
|
1294
|
-
attr("langfuse.trace.metadata.model", event.model),
|
|
1295
|
-
attr("langfuse.trace.metadata.provider", event.provider),
|
|
1296
1284
|
attr("langfuse.observation.metadata.agent", event.agent),
|
|
1297
1285
|
attr("langfuse.observation.metadata.host", currentHost),
|
|
1298
1286
|
attr("langfuse.observation.metadata.machine", currentHost),
|
|
@@ -1303,8 +1291,6 @@ function toOtlp(events, options = {}) {
|
|
|
1303
1291
|
attr("langfuse.observation.metadata.model", modelName ?? event.model),
|
|
1304
1292
|
attr("langfuse.observation.metadata.provider", event.provider),
|
|
1305
1293
|
attr("langfuse.observation.metadata.cost_source", cost?.source),
|
|
1306
|
-
attr("langfuse.trace.input", event.input),
|
|
1307
|
-
attr("langfuse.trace.output", event.output),
|
|
1308
1294
|
attr("langfuse.observation.input", event.input),
|
|
1309
1295
|
attr("langfuse.observation.output", event.output),
|
|
1310
1296
|
attr("source.path", event.sourcePath),
|
|
@@ -1331,7 +1317,7 @@ function toOtlp(events, options = {}) {
|
|
|
1331
1317
|
status: { code: 1 },
|
|
1332
1318
|
};
|
|
1333
1319
|
});
|
|
1334
|
-
return [rootSpan, ...childSpans];
|
|
1320
|
+
return shouldEmitRootSpan ? [rootSpan, ...childSpans] : childSpans;
|
|
1335
1321
|
});
|
|
1336
1322
|
return {
|
|
1337
1323
|
resourceSpans: [
|