Skip to content

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

Open
mquang-amazon wants to merge 4 commits into
v1.xfrom
test/e2e-otel-traces-v1.x
Open

mquang-amazon wants to merge 4 commits into
v1.xfrom
test/e2e-otel-traces-v1.x

Conversation

@mquang-amazon

@mquang-amazon mquang-amazon commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

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 (assertTelemetry in e2eTest/project/templates.test.ts):

  • OpenTelemetry logs: the agent's logs reach CloudWatch, queried by the runtime's service name.
  • Trace of the invoke: agentcore traces runtime list --json has a trace whose sessionId is the invoke's session, and traces 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.
  • Box templates only: box's policy records (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 (telemetry on 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 get TELEMETRY_TIMEOUT (20 min) more.

Testing

  • tsc --noEmit and oxlint pass.
  • Local deploy of the non-Box agent_python_strands: the log, trace and agent span checks pass.
  • First full e2e run, us-west-2: https://github.com/aws/agentcore-cli/actions/runs/46642391316
    • The telemetry checks passed for agent_python_strands, agent_python_minimal, agent_python_langchain, a2a_python_strands, agui_python_strands, py_strands_container and the Box templates.
    • They failed for agent_ts_strands, agent_ts_vercel and mcp_python_fastmcp (no log records) and for agent_python_minimal_box (no policy records), which the second commit fixes as above.
    • The tui deploy 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.
  • Full e2e run with the fix (2c275ac0), us-east-1: https://github.com/aws/agentcore-cli/actions/runs/46657417033
    • No telemetry check failed: every template that runs them passed, the Box templates with their policy records and box span. Windows passed.
    • The other failures were CloudFormation throttling while other e2e runs deployed to the same account (agent_python_strands, agent_ts_vercel, tui OpenAICompatible and LiteLLM), and the tui LiteLLM dev start on Linux arm64 (Could not reach local dev server), which v1.x has without this change too.

@mquang-amazon
mquang-amazon requested a review from a team December 1, 2026 12:02
@github-actions github-actions Bot added the size/m PR size: M label Dec 1, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-1.4.0.tgz

How to install

gh 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

@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Dec 1, 2026

@agentcore-devx-automation agentcore-devx-automation Bot 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.

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 same retry that resolves traceId (re-listing is cheap and keeps one deadline), or
  • Wrap the get + assertions in their own retry with 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?: boolean on RuntimeTemplateTestCase) 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_fastmcp initialize-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.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Dec 1, 2026
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Dec 1, 2026
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.
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Dec 1, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Dec 1, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Dec 1, 2026
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Dec 1, 2026

This branch has not been deployed

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

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant