Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat: add gcp vertex tool inputs and outputs on otel spans (#9074)

Steffen Schmitzedfb15c010f9
diff --git a/packages/shared/src/server/otel/OtelIngestionProcessor.ts b/packages/shared/src/server/otel/OtelIngestionProcessor.ts
index 38e6e310d7..e6313660d0 100644
--- a/packages/shared/src/server/otel/OtelIngestionProcessor.ts
+++ b/packages/shared/src/server/otel/OtelIngestionProcessor.ts
@@ -1080,6 +1080,13 @@ export class OtelIngestionProcessor {
return { input, output };
}
+ // GCP Vertex Agent Tool call input and output
+ input = attributes["gcp.vertex.agent.tool_call_args"];
+ output = attributes["gcp.vertex.agent.tool_response"];
+ if (input || output) {
+ return { input, output };
+ }
+
// TraceLoop uses attributes property
const inputAttributes = Object.keys(attributes).filter((key) =>
key.startsWith("gen_ai.prompt"),
diff --git a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts b/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
index 8f1e2ef2a7..4057bc3f4a 100644
--- a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
+++ b/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
@@ -492,6 +492,7 @@ describe("OTel Resource Span Mapping", () => {
environment: "production",
});
});
+
it("should throw an error if langfuse scope spans have wrong project ID", async () => {
const langfuseOtelSpans = [
{
@@ -2019,6 +2020,30 @@ describe("OTel Resource Span Mapping", () => {
entityAttributeValue: '{"foo": "bar"}',
},
],
+ [
+ "should map gcp.vertex.agent.tool_call_args to input",
+ {
+ entity: "observation",
+ otelAttributeKey: "gcp.vertex.agent.tool_call_args",
+ otelAttributeValue: {
+ stringValue: '{"foo": "bar"}',
+ },
+ entityAttributeKey: "input",
+ entityAttributeValue: '{"foo": "bar"}',
+ },
+ ],
+ [
+ "should map gcp.vertex.agent.tool_response to output",
+ {
+ entity: "observation",
+ otelAttributeKey: "gcp.vertex.agent.tool_response",
+ otelAttributeValue: {
+ stringValue: '{"foo": "bar"}',
+ },
+ entityAttributeKey: "output",
+ entityAttributeValue: '{"foo": "bar"}',
+ },
+ ],
])(
"Attributes: %s",
async (