Skip to content

Concept Observability

Reese Hodge edited this page Nov 19, 2026 · 8 revisions

Observability

Branch review qualification (2026-11-15)

Source-Agent-Infra-Deployment-Review checks the architecture-review branch's application tracing: its timing records are JSON logs, not exported OpenTelemetry spans, and overlapping requests collide by span name. Provider, request context, exporter and live AgentCore visibility are release gates under P9. Node.js instrumentation still needs verification against the pinned SDK and AWS's setup; Python examples are not an implementation recipe here.

ADOT review (2026-11-16, spec 003 T168b, research.md § R-obs).

  • Under node --require …/register, spans from our ESM code reach ADOT's NodeTracerProvider. Only its require()-patching auto-instrumentation is lost. AWS's Node guide says ESM makes ADOT "silently fail", which is true of that auto-instrumentation only.
  • Two findings block adopting it as-is:
    • With AGENT_OBSERVABILITY_ENABLED, it defaults GenAI message-content capture on, and logs and metrics exporters on.
    • 0.13.0 pins exact OpenTelemetry versions carrying 4 high and 14 moderate advisories, which would fail Audit.
  • Trace export (T169b) waits on a builder decision between overriding those pins, a small exporter we own (upstream OTLP plus SigV4), or accepting the advisories.
  • Transaction Search is account-wide and one-time, and no deploy step enables it yet.

Adopted (2026-11-16, T169b, main-repo f05485f). The builder chose ADOT with scoped overrides.

  • packages/agent depends on @aws/aws-distro-opentelemetry-node-autoinstrumentation@0.13.0, and the Dockerfile starts node --require …/register dist/index.js.

  • pnpm-workspace.yaml carries 12 overrides scoped to ADOT's edges, which lift the vulnerable OpenTelemetry pins to patched versions. pnpm audit is clean. A local console-exporter run proved the patched set still works. Remove the overrides when an ADOT release ships those versions.

  • RUNTIME_CONFIG in agent-stack.ts sets five variables:

    • AGENT_OBSERVABILITY_ENABLED=true
    • OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=false, because friends' messages are personal data.
    • OTEL_LOGS_EXPORTER=none and OTEL_METRICS_EXPORTER=none.
    • UNIFIED_TRACES_DESTINATION_ENABLED=false. With true, spans go to the runtime's own log group, which needs logs:PutResourcePolicy.

    A test in agent-stack.test.ts pins all five.

  • Transaction Search is now in CDK (5417448). OpsStack.enableTransactionSearch() creates the X-Ray resource policy, then CfnTransactionSearchConfig, then a LogRetention that keeps aws/spans for 14 days. Deleting the stack turns Transaction Search off but keeps the log group.

  • Still unverified until T174 runs live: that AgentCore Runtime's injected OTEL_* variables do not override ours, and that spans reach X-Ray.

Trap: do not declare the aws/spans log group

X-Ray creates aws/spans itself when Transaction Search is enabled, and enabling fails if the group already exists. Set its retention with LogRetention after the config, rather than declaring an AWS::Logs::LogGroup. That LogRetention adds a Lambda, which is why the feature lives in OpsStack: AgentStack asserts it has no Lambda functions.

Tool faults can look healthy

AWS's Source-AWS-AgentCore-Resilience-Testing reports an experiment where tool calls failed or returned corrupted data while CloudWatch error metrics stayed at zero and every runtime invocation returned HTTP 200. Availability signals alone therefore cannot show whether a tool-dependent answer used valid data. For such paths, observe tool outcomes, output validation, and task success as well as transport and runtime status. This is source guidance; it does not claim those signals are currently implemented for every Max Height tool.

Observability is constitution principle P9. If production behavior cannot be seen in traces, metrics, or logs, it must not ship.

The constitution requires trace-first development:

  • AgentCore Observability must be wired before the second feature.
  • Every user-visible latency target must have a corresponding trace span.
  • Personality regressions must be diagnosable from traces and logs without requiring a reproduction.

The quality gate repeats the rule: trace spans must exist for every user-visible latency path before the feature ships.

For code, this means new behavior needs instrumentation at the same time as the behavior itself. Do not add an agent step, TTS operation, WebSocket path, fallback state, or user-visible latency budget without a way to see it in production.

Useful implementation questions:

  • Can a developer tell where time was spent for this user-visible action?
  • Can a failed cloud call be distinguished from a client capability failure?
  • Can a personality regression be tied back to prompts, tools, or agent state?
  • Can cost-relevant usage be correlated with the session path that caused it?

Observability is the debugging substitute for a larger QA and operations team. It supports Concept-Budget-Ceiling by making expensive paths visible, and it supports Concept-Personality-Gate by making behavior regressions traceable instead of anecdotal.

Retention and cost gap before the first deployment

Neither the WebSocket Lambda in agent-stack.ts nor the hard-stop Lambda in budget-stack.ts declares a log group or sets log retention. The CDK stacks do not set retention for any log destination. AWS documents that CloudWatch Logs retains Lambda logs indefinitely by default and charges for storage; ingestion can also cost money. This is a latent deployment gap, not a claim that any logs already exist: nothing has been deployed. Retention and logging levels need deliberate choices that preserve P9's traceability and P2's budget. Spec 003 FR-022 requires explicit retention for every log destination and a recorded decision on billed observability and model-invocation logging. See Component-Infra-Stacks.

What spec 003's plan decided

These are plan decisions, not deployed configuration (see Source-Spec-003):

  • 14-day retention on every log group, set explicitly in CDK, at level INFO, and friends' message text is never logged.
  • Transaction Search is on, because P9 requires traces. The aws/spans log group also gets 14 days. Source-AWS-Infrastructure-Pricing now records the Oregon ingestion, storage, query and indexing rates, checked against AWS on 2026-11-01. Default 1% indexing is free, not the full span ingestion. Human confirmation and projected telemetry volume remain pending.
  • Model-invocation logging is off, because friends' messages are personal data.

CDK's own Lambdas need retention too

Retention on our own functions is not enough. When a Lambda function runs and its /aws/lambda/<name> group does not exist, Lambda creates one that never expires. CDK synthesizes Lambdas we never wrote:

  • crossRegionReferences deploys an export writer and reader. Both are CustomResourceProvider functions, which emit a bare AWS::Lambda::Function with no log group and no LoggingConfig. custom-resource-provider-base.js in aws-cdk-lib 2.272.0 mentions neither, re-checked 2026-10-11.
  • BucketDeployment and the cr.Provider framework Lambda both accept a logGroup prop, so they can be fixed where they are built.

The plan passes a 14-day group wherever a prop exists. For everything else, an app-wide Aspect gives each function a pre-created 14-day group. A test asserting that every synthesized AWS::Lambda::Function names such a group proves whether the Aspect reaches CDK-internal functions; do not assume it.

Shipping checklist

A feature is not observable merely because it logs errors. Before shipping, confirm:

  • The start and end of the user-visible path are represented.
  • Slow paths can be separated from failed paths.
  • Cloud calls, fallback decisions, and user-visible state changes can be correlated.
  • Cost-relevant operations have enough context to explain spend.
  • Each log destination has an explicit retention period and its cost is included in the deployment's projection.
  • Logs do not contain credentials, account identifiers, or secret-bearing URLs.

Prefer structured events and spans over prose-only logs. Prose helps humans, but structured fields let a future agent or dashboard answer "what changed?" without rereading every transcript.

If instrumentation would expose sensitive data, fix the data shape rather than dropping the telemetry.

See also: Source-Constitution, Concept-Graceful-Degradation.

Clone this wiki locally