Skip to content

feat(google-adk): add ADK instrumentation and e2e coverage#1765

Draft
Abhijeet Prasad (AbhiPrasad) wants to merge 1 commit intomainfrom
feat/google-adk-instrumentation
Draft

feat(google-adk): add ADK instrumentation and e2e coverage#1765
Abhijeet Prasad (AbhiPrasad) wants to merge 1 commit intomainfrom
feat/google-adk-instrumentation

Conversation

@AbhiPrasad
Copy link
Copy Markdown
Member

resolves #1477

Add Braintrust instrumentation for @google/adk with auto-instrumentation support by default when users run with Braintrust's loader hook.

This adds tracing for:

  • Runner.runAsync
  • BaseAgent.runAsync and subclasses
  • FunctionTool.runAsync

It also adds Google ADK e2e coverage for both hook-driven and wrapped execution.

Because ADK uses @google/genai under the hood, underlying LLM spans continue to come from the existing Google GenAI instrumentation.

Recommended usage: auto-instrumentation

The primary way users should adopt this is via Braintrust auto-instrumentation:

node --import braintrust/hook.mjs app.mjs

Then they can use @google/adk normally and Braintrust will trace supported ADK operations automatically.

Example:

import * as adk from "@google/adk";
import { initLogger } from "braintrust";

initLogger({ projectName: "my-google-adk-app" });

const agent = new adk.LlmAgent({
  name: "weather_agent",
  model: "gemini-2.5-flash-lite",
  instruction: "Answer weather questions",
});

const runner = new adk.InMemoryRunner({ agent, appName: "weather-app" });

await runner.sessionService.createSession({
  appName: runner.appName,
  userId: "user-1",
  sessionId: "session-1",
});

for await (const event of runner.runAsync({
  userId: "user-1",
  sessionId: "session-1",
  newMessage: {
    role: "user",
    parts: [{ text: "What's the weather in Paris?" }],
  },
})) {
  console.log(event);
}

If needed, it can be disabled with:

BRAINTRUST_DISABLE_INSTRUMENTATION=google-adk node --import braintrust/hook.mjs app.mjs

Manual usage

Manual wrapping is also available for cases where users want explicit control:

import * as adk from "@google/adk";
import { wrapGoogleADK } from "braintrust";

const wrapped = wrapGoogleADK(adk);

Testing

  • added Google ADK plugin/unit coverage
  • added Google ADK e2e scenario and snapshots
  • validated both auto-hook and wrapped execution paths

Add manual and load-time instrumentation for `@google/adk` across runner,
agent, and tool execution. This introduces the wrapper entrypoint,
tracing-channel plugin, vendored SDK types, exports, and loader config needed
to emit Braintrust spans for Google ADK workflows.

Add a dedicated Google ADK e2e scenario with a committed lockfile and stable
snapshots for both wrapped and hook-driven execution.

Stabilize the scenario by pre-creating ADK sessions, letting the loader hook
respect `BRAINTRUST_DISABLE_INSTRUMENTATION`, and normalizing volatile outputs
in the assertions so the coverage stays repeatable.
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) marked this pull request as draft April 9, 2026 03:55
@AbhiPrasad
Copy link
Copy Markdown
Member Author

wait this need some more work. I realized the parent child relationships are wrong 😢

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests in this entire file seem rather shallow. Would honestly just remove them to spare our clankers from using context for them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add the google-adk scenarios to the e2e test summary for CI. I've used that quite a bit.

@lforst
Copy link
Copy Markdown
Member

wait this need some more work. I realized the parent child relationships are wrong 😢

I honestly don't know why this is so painful in this SDK. Tracing channels make it harder because they are event based. It should honestly just be a simple wrapping call imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integration for Google Agent Development Kit (ADK) for TypeScript

2 participants