Repository navigation
test(e2e): Check the agent's OpenTelemetry logs and the invoke's trace in each deploy test, and box's records and spans in the Box ones - #2984
Conversation
…y records and its traces reach CloudWatch
…e in every template deploy test, and box's records and spans in the Box ones
Package TarballHow to installgh release download pr-2984-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-1.4.0.tgz |
|
Claude Security Review: no high-confidence findings. (run) |
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Changes requested
The new assertTelemetry helper is well targeted (it picks the trace by session, so box's own start trace can't satisfy the check), and the getSessionId hoist at templates.test.ts:304/:425 is necessary since the id embeds Date.now(). Three things to resolve before merge.
1. The trace-content assertions are outside any retry (e2eTest/project/templates.test.ts:1439-1463)
The retry only covers the traces runtime list lookup, which succeeds as soon as one span carrying attributes.session.id is indexed. The traces runtime get download and the two span assertions then run exactly once:
expect(spans.some((span) => span.includes(service))).toBe(true);
if (box) expect(spans.some((span) => span.includes("strands.box"))).toBe(true);For a Box runtime the agent's spans and box's own spans come from different exporters/batches, so a trace that is visible but not yet complete fails the test immediately instead of waiting — exactly the flake this helper is meant to tolerate elsewhere. traces runtime get also throws ResourceNotFoundError (CLI exit ≠ 0 → parseResult throws) if the records aren't queryable yet, with no second attempt.
Options:
- Move the
get+ both span assertions inside the sameretrythat resolvestraceId(re-listing is cheap and keeps one deadline), or - Wrap the
get+ assertions in their ownretrywith its own deadline.
While you're there, consider matching the diagnostic style of assertRunsInBox (explicit Error including stdout/stderr); a bare expected false to be true after a 10-minute wait is hard to triage in CI.
2. assertTelemetry is applied to every template in the matrix, including ones that likely emit no OTel
templates.test.ts:355 runs it unconditionally for all of RUNTIME_TEMPLATES, which includes agent_ts_strands and agent_ts_vercel. The Python templates run under opentelemetry-instrument with aws-opentelemetry-distro (see each pyproject.toml), but the TypeScript templates depend only on @opentelemetry/api (src/assets/templates/agent-typescript-strands/package.json.template, and agent-typescript-vercel has no OTel dep at all); bedrock-agentcore (npm) ships no OTel SDK/exporter and @strands-agents/sdk lists the SDK/exporter packages only as optional peers. With no SDK registered, @opentelemetry/api is a no-op, so neither OTLP log records with "resource" nor spans should reach the runtime log group — the new checks would burn ~15 min and then fail those two tests. The PR description confirms only agent_python_strands has been verified.
Options:
- Gate it with a per-case field (e.g.
telemetry?: booleanonRuntimeTemplateTestCase) and set it on the templates known to be instrumented; - Derive it from the template language (skip the TypeScript ones) with a comment saying why; or
- If the full matrix run that's "in progress" shows the TS (and
agent_python_minimal/mcp_python_fastmcpinitialize-only) cases do produce the records, say so in the PR and leave it unconditional.
Please don't merge until the full run has covered every case this now gates.
3. TELEMETRY_TIMEOUT is smaller than the worst case it is meant to cover (templates.test.ts:1467)
Worst case inside assertTelemetry for a Box case is 5 min (agent logs) + 5 min (policy records) + 10 min (trace lookup) = 20 min of retries, plus the traces get call — i.e. ≥ the 20 min added to the test timeout at :307 and :423. When telemetry is slow but eventually lands, the test can hit Vitest's timeout before the helper's own deadline, replacing the retry's error with an opaque "test timed out". Either raise the constant (e.g. 25-26 min) or shorten the per-check deadlines so the sum fits.
Also note the box span path depends on box ≥ 0.3.2 writing spans to the runtime's log group (docs/box-local-testing.md:585-588); with an older box they land in aws/spans and strands.box will never be found. A comment near the box assertion stating that minimum would save the next person a 20-minute debug.
The TypeScript templates have no OpenTelemetry SDK and the FastMCP server sends no log records, so their deploy tests skip assertTelemetry. The minimal Box agent makes no outbound call, so box records no policy decision for it, and its test skips that one check. The full e2e run had failed these four on every runner.
|
Claude Security Review: no high-confidence findings. (run) |
Summary
The e2e deploy tests invoked each template and checked the response, but not that its telemetry reached CloudWatch. They now check it after each deployed invoke (
assertTelemetryine2eTest/project/templates.test.ts):agentcore traces runtime list --jsonhas a trace whosesessionIdis the invoke's session, andtraces runtime get <id>holds a span of the agent (<project>_default_agent.DEFAULT). The trace is picked by session, because a Box runtime also writes box's own start trace.strands.box.policy.verdict) reach the Runtime's logs, and the invoke's trace has a box span (strands.box).It runs in the runtime templates suite (the Box checks when the template is a Box one) and in the Box flow suite. A template checks only the telemetry it sends (
telemetryon its test case): the TypeScript templates have no OpenTelemetry SDK and the FastMCP server sends no log records, so they skip the checks ("none"); the minimal Box agent makes no outbound call, so box records no policy decision for it, and it skips that check ("no-policy-records"). Telemetry takes minutes to land, so the log checks retry for up to 5 min and the trace lookup for up to 10 min; the tests that call it getTELEMETRY_TIMEOUT(20 min) more.Testing
tsc --noEmitandoxlintpass.agent_python_strands: the log, trace and agent span checks pass.agent_python_strands,agent_python_minimal,agent_python_langchain,a2a_python_strands,agui_python_strands,py_strands_containerand the Box templates.agent_ts_strands,agent_ts_vercelandmcp_python_fastmcp(no log records) and foragent_python_minimal_box(no policy records), which the second commit fixes as above.tuideploy tests and the env:// key egress test failed on the CI account's quota of API key credential providers in us-west-2, not on these checks.2c275ac0), us-east-1: https://github.com/aws/agentcore-cli/actions/runs/46657417033agent_python_strands,agent_ts_vercel,tuiOpenAICompatible and LiteLLM), and thetuiLiteLLM dev start on Linux arm64 (Could not reach local dev server), whichv1.xhas without this change too.