Skip to Content
Recodocs

AgentCore observability

What does AgentCore record for a kit run when Transaction Search is off?

6 min read

What question this set answers

A trace answers what happened on one run. An observability contract helps the operator find that trace and interpret it consistently across the application and hosted runtime.

A platform engineer makes kit runs hosted on Amazon Bedrock AgentCore Runtime traceable, then checks what the account records. The kit owner is recohut_kit.agentcore.observability.

SpanContract, bind_contract and contract_span_processor stamp recohut.run.id, recohut.agent.id, session.id and recohut.tool.names on every span started under bind_contract; a span started outside that scope is exported unlabelled unless require_binding=True, which refuses to start it. Tool spans add gen_ai.tool.name. span_contract_gaps reports missing attribution. The same attributes feed recohut_kit.latency.otel.latency_span_processor. configure_agentcore_export routes are in-process (a caller exporter), local-otlp (native OTLP/HTTP, the exporter the kit's Phoenix bridge uses), and agentcore-adot (the contract processor on the ADOT-owned provider inside an AgentCore container). Readback is fetch_runtime_logs (FilterLogEvents on /aws/bedrock-agentcore/runtimes/<runtime id>-DEFAULT), fetch_xray_traces (GetTraceSummaries then BatchGetTraces), and match_receipts → TraceMatch.

Notebooks 1 and 2 are for the platform engineer, and notebook 3 is for the on-call engineer. A fixed span script stands in for a model. Nothing in them is an agent. Notebook 4 is for the on-call engineer. It observes the deploy set's calculator runtime, a native strands.Agent driven by Nova Micro, and makes no claim about answer quality. Notebook 5 is for an engineering lead who needs notebook 4's units and a statement of what was and was not observable.

How to run it

From the kit root, on Python 3.13. No pin, pyproject.toml or project.yaml value is changed. Installed versions are in docs/agentcore-observability/versions.json. aws-opentelemetry-distro is absent from this environment. It exists only in .venv-agentcore-deploy and in the deployed container (examples/agentcore-runtime-deploy/runtime_agent/Dockerfile runs opentelemetry-instrument).

uv venv --python 3.13 .venv-agentcore-observability
uv pip install --python .venv-agentcore-observability/bin/python \
  -e '.[agentcore,latency]' -e packages/strands nbconvert ipykernel pandas ruff
.venv-agentcore-observability/bin/python -m ipykernel install --user \
  --name agentcore-observability --display-name agentcore-observability

Execute each notebook once, in order, from the kit root. Do not rerun a notebook to obtain cleaner output. A failed attempt stays in notebook-attempts.json. Execution status, attempts and consumed units are authoritative in docs/agentcore-observability/agentcore-observability-verification.md.

.venv-agentcore-observability/bin/jupyter nbconvert --to notebook --execute --inplace \
  --allow-errors --ExecutePreprocessor.timeout=900 \
  --ExecutePreprocessor.kernel_name=agentcore-observability \
  examples/agentcore-observability/<notebook>.ipynb
.venv-agentcore-observability/bin/python scripts/check_agentcore_observability_notebooks.py \
  examples/agentcore-observability/*.ipynb --executed --aws-profile recohut

The kernel name is agentcore-observability. Each notebook's text says it creates .runtime/<notebook>/ and deletes that directory in its last cell. obsdesk.py holds the span script, the loopback receiver, the synthetic CloudWatch Logs and X-Ray responses (recorded, not a capture of a real account; ids from fixed seeds), and the two live-lane loops. The kit owns the contract, export configuration and readback parsing. The account owns where spans go. Settings are read, never changed. The README gives the X-Ray segment destination as XRay and Transaction Search as not enabled. Notebook 4 stops the two sessions it opens, appends docs/agentcore-observability/aws-units.jsonl, and writes redacted live-matches.json for notebook 5. It stops if the runtime-deploy handoff is absent. Notebook 5 stops if that handoff or notebook 4's evidence is missing. Its route is AWS live, profile recohut, us-east-1, read-only: one ListMetrics page and a tagging readback. The runtime is destroyed only by the deploy set's notebook 7.

Notebooks in order

NotebookWhat it doesRecorded output
01-span-contract-in-process.ipynbRefuses bad identifiers, stamps contract attributes, flags an undeclared tool. The proof text also names baggage, unbound spans, LatencyFact rows and a log-line round trip. Scripted. 0 AWS, 0 model calls.yes (12)
02-local-otlp-lane.ipynbCollector-URL refusals, ADOT route refusal, processor-only behaviour on an ADOT-owned provider, and a loopback OTLP/HTTP post. Scripted, loopback HTTP, 0 AWS calls.yes (11)
03-recorded-logs-and-xray.ipynbStubbed log-group checks, paged FilterLogEvents, three log shapes, absent and denied outcomes, X-Ray segments and TraceMatch statuses. Recorded, 0 AWS calls.yes (12)
04-live-logs-and-traces.ipynbReads the runtime-deploy handoff, invokes the deployed runtime twice, stops each session, and reads logs and traces. AWS live: 2 InvokeAgentRuntime and 2 StopRuntimeSession, plus bounded reads.yes (11)
05-units-and-observability-matrix.ipynbUnits from notebook 4's ledger, one ListMetrics page, the observability matrix, and tagged inventory. AWS live read-only.yes (7)

What the recorded outputs show

Notebook 1. Four contracts raise ValueError and do not echo too-short. The cell prints ✓ Invalid identifiers refused; rejected values are not echoed. The route line is route: in-process | owns provider: True | notes: ('InMemorySpanExporter',). The redacted contract shows run run-obs-0001, agent orderdesk, session …000001, tools lookup_order and check_stock. The scripted run prints spans started: 5 | finished: 5 | gaps: 0 and undeclared tool spans: ['execute_tool delete_order']. The table names chat us.amazon.nova-micro-v1:0, execute_tool lookup_order, execute_tool check_stock, execute_tool delete_order and invoke_agent orderdesk.

Notebook 2. Six local-otlp calls raise ExportRefused, with codes invalid_endpoint, exporter_unused and invalid_service_name. This kernel prints global provider: ProxyTracerProvider | ADOT active: False, then adot_not_active and adot_owns_export. A stand-in ADOT provider prints route: agentcore-adot | owns provider: False, notes ('exporters owned by ADOT', 'delivery proven only by readback'), and spans: 4 contract + 1 after kit shutdown.

Notebook 3. The notebook says no network call is made. Receipts are run-obs-a, run-obs-b and run-obs-c. The log group is /aws/bedrock-agentcore/runtimes/obsdesk_agent-Rec0rded01-DEFAULT. The check prints aws/spans present: False | runtime group present: True. Session A has three events on two pages (runtime-logs twice, otel-rt-logs once) at 2026-10-19T06:05:00+00:00. Only the first has contract true and run id run-obs-a. The OTel row has trace suffix …280577 and no run id. Session B has one plain line at 2026-10-19T06:06:00+00:00. Session C has none. Pages are {'run-obs-a': 2, 'run-obs-b': 1, 'run-obs-c': 1}. The assertion cell prints checks passed: log events by session asserted.

Notebook 4. The handoff prints runtime: …G8F5Iu | agent: kit_runtime_deploy_calc | region: us-east-1 and log group …Q6G8F5Iu-DEFAULT. Settings are segment_destination XRay, status ACTIVE, transaction_search_enabled false, aws_spans_group false, runtime_group true, tagged before: 0. Two calls complete and stop: 215997cf-90ef-4aaa-9a80-f876dc90eb7d in 2.480 seconds (session …a71296) and 57a2ffc2-1415-49e4-8ff8-f4d33b029254 in 2.009 seconds (session …7f52bb). Printed session id length is 40. The handler text is cut at {'actor': 'iam-invoker', 'model_id': 'us.amazo. The code prompt is Use the add tool to compute 2 + 3.

Notebook 5. It reloads those settings from live-matches.json. Notebook 4's ledger groups as InvokeAgentRuntime 2 calls and 2 ok, StopRuntimeSession 2 and 2, DescribeLogGroups 2 and 2, FilterLogEvents 2 and 2, BatchGetTraces 1 and 1, GetTraceSegmentDestination 2 and 2. GetTraceSummaries shows 1 call; the row ends before the ok column. The print is runtime invocations: 2 | upper-bound runtime USD (estimate): 0.00723, from assumed 120 seconds, 1 vCPU and 2 GB at USD 0.0895 per vCPU-hour and USD 0.00945 per GB-hour (checked 2026-10-19), under BUDGET_USD 0.20. The notebook calls the dollar figure an upper-bound estimate from those stated assumptions, using the ledger for the invocation count. ListMetrics prints Bedrock-AgentCore metric names (first page): [].

What is not shown

All five notebooks have recorded outputs (12, 11, 12, 11, 7). None is marked as not run in the saved file. The extract stops inside a later cell of each notebook, so those later outputs are not included here.

Notebook 1 names baggage session.id, unbound spans, LatencyFact rows and a parse_log_event round trip, and its attribute dump is cut at print. Notebook 2's loopback cell is cut at sink = od., so no decoded OTLP body is included. The notebook says that ADOT stand-in does not prove delivery to AWS. The notebook text says a Phoenix container happened to listen on port 6006 and belongs to another workflow; the sentence is cut. Notebook 3 is cut at "filte, so no included output shows a missing group, ObservabilityReadError(code="denied"), X-Ray segments, or TraceMatch rows. The proof text names logs_and_traces, logs_only and unobserved; the idea text says this notebook does not tell you what a real account currently emits, and that notebooks 4 and 5 do. Notebook 4's log section is cut before any live log or trace readback. Its proof text says session ids are 37 characters; the saved print says 40. Notebook 5's extract includes the matrix mapping and the display call, and cuts inside the following match statuses print, so the displayed table, status values and closing tagged-inventory line are not in the saved output. The only tagged-inventory figure in a saved output is notebook 4's tagged before: 0. The README says notebooks 4 and 5 end with a zero count for recohut-kit-agentcore=agentcore-observability. The empty ListMetrics page is the first page only.

Where it fits in the kit

Notebooks 1–4 import recohut_kit.agentcore.observability. Notebook 1 also imports recohut_kit.latency.otel (latency_span_processor). Notebook 4 imports recohut_kit.agentcore.runtime (AgentCoreRuntime, new_session_id). Notebooks 4 and 5 load agentcore_live from agentcore-common. Notebooks 1–4 import obsdesk. Included cells also import json, shutil, sys, importlib, datetime, functools, pathlib, pandas, IPython.display, opentelemetry (baggage, trace, TracerProvider, SimpleSpanProcessor, InMemorySpanExporter) and botocore (Stubber, ANY, Config).

How is this page?

Last updated on