Skip to content

AI-471 Add Google ADK metrics sample - #530

Merged
xumaple merged 3 commits into
mainfrom
maplexu/AI-471-adk-metrics
Sep 10, 2026
Merged

AI-471 Add Google ADK metrics sample#530
xumaple merged 3 commits into
mainfrom
maplexu/AI-471-adk-metrics

Conversation

@xumaple

@xumaple xumaple commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

This PR adds a Google ADK sample that exports successful model-call and token-usage metrics through Temporal’s replay-aware Workflow metrics handler. It includes a Prometheus worker, starter, and API-key-free tests for exact metric values and missing usage metadata.

@xumaple
xumaple requested review from a team as code owners August 25, 2026 19:30

@DABH DABH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The design is right, and I checked the load-bearing part rather than assuming it: ADK runs AfterModelCallback synchronously on the Workflow goroutine (base_flow.go:783 -> :804, no goroutine), so capturing workflow.GetMetricsHandler(ctx) at workflow.go:24 is legal, and .WithTags preserves the replay-aware wrapper. Choosing that over sdktally.ScopeFromHandler is the one decision that makes this replay-safe, and contrib/tally's handler.go:54-56 warns about exactly the trap you avoided. Counter semantics are right too — TemporalModel.GenerateContent yields one aggregated response per turn, and Activity retries are invisible to the Workflow, so model_calls is genuinely one-per-turn with no retry inflation.

Two things that aren't tied to a line in this diff:

The sample isn't registered anywhere. The root README.md:176-181 Google ADK bullet names all three existing scenarios and links them; googleadk/README.md:23-37 lists four. Neither mentions metrics/, and this diff touches only the five files under googleadk/metrics/, so there is no path to this sample from any index. Extending the root bullet:

signal), a [continue-as-new chat](./googleadk/chat), and [model-usage
metrics](./googleadk/metrics).

and a fifth bullet in googleadk/README.md:

- **[metrics/](metrics)** — records per-model-call token usage from
  `LLMResponse.UsageMetadata` onto Temporal's replay-aware Workflow metrics
  handler, exported via Prometheus.

CI hasn't actually validated any of this. build-and-test failed at staticcheck on a pre-existing SA1019 in temporal-fixtures/rainbow-statuses/starter/main.go:47, and since Makefile:57 is ci-build: staticcheck errcheck workflowcheck bins test, the abort means errcheck, workflowcheck, bins and test never ran on this branch. I ran all five locally and they're green, so nothing is hiding — but the green-looking gate here is worth knowing about, and it'll keep failing for unrelated reasons until that fixture is fixed separately.

Comment thread googleadk/metrics/workflow.go
Comment thread googleadk/metrics/workflow.go
Comment thread googleadk/metrics/workflow.go
Comment thread googleadk/metrics/workflow.go Outdated
Comment thread googleadk/metrics/workflow.go Outdated
Comment thread googleadk/metrics/workflow_test.go
Comment thread googleadk/metrics/README.md Outdated
Comment thread googleadk/metrics/README.md Outdated

@DABH DABH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@xumaple
xumaple force-pushed the maplexu/AI-471-adk-metrics branch from faa6a92 to f759656 Compare September 10, 2026 16:40
@xumaple
xumaple requested a review from a team as a code owner September 10, 2026 16:40
@xumaple
xumaple merged commit 42159e3 into main Sep 10, 2026
4 checks passed
@xumaple
xumaple deleted the maplexu/AI-471-adk-metrics branch September 10, 2026 20:37
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.

3 participants