Observability
The Agent SDK has a 3-layer observability architecture:
| Layer | Tool | Scope |
|---|---|---|
| Proxy | Prometheus via isa_common.metrics | HTTP gateway metrics (latency, error rates, tokens) |
| Agent | OpenTelemetry via TracingManager | Service call spans (model, tool, memory, session) |
| Training | Agent Lightning | RL training data (rollouts, rewards) |
All three layers are independent and compose additively.
OpenTelemetry Tracing
Setup
# Install OTel dependencies
pip install "aix-agent-sdk[observability]"
# Enable via environment
export ISA_TRACING_ENABLED=true
export ISA_TRACING_EXPORTER=otlp # otlp, console, or none
export ISA_TRACING_SERVICE_NAME=aix-agent-sdk
export ISA_TRACING_SAMPLING_RATE=1.0 # 0.0-1.0Service Call Tracing
Wrap any async service call with a span:
from agent_sdk.observability import trace_service_call
async with trace_service_call("model", "call_model", model="claude-3") as span:
result = await model_client.call(...)
# Span auto-records: duration, status, error (if raised)Programmatic Configuration
from agent_sdk.observability import configure_tracing, TracingConfig
configure_tracing(TracingConfig(
enabled=True,
service_name="my-agent",
sampling_rate=0.5,
exporter="otlp",
))Tracing Metrics
from agent_sdk.observability import tracing_metrics
m = tracing_metrics()
# {"enabled": True, "spans_created": 142, "spans_dropped": 0}Metrics Reference
Circuit Breaker
| Metric | Description |
|---|---|
cb_state{service} | 0=closed, 1=open, 2=half_open |
cb_failure_count{service} | Total failures |
cb_success_count{service} | Total successes |
Bulkhead
| Metric | Description |
|---|---|
bulkhead_active{pool} | Currently occupied slots |
bulkhead_queued{pool} | Requests waiting |
bulkhead_total_exhausted{pool} | Timeout exhaustions |
MCP Fallback
| Metric | Description |
|---|---|
mcp_fallback_active | 1 if fallback mode |
mcp_fallback_activation_count | Times fallback activated |
mcp_fallback_cached_tools | Cached tool schemas |
Model Usage
Recent SDK counters expose model-call volume, token usage, and cost attribution for agent runs.
| Metric | Description |
|---|---|
model_calls | Number of model calls issued by the agent runtime |
tokens_in | Input tokens sent to model providers |
tokens_out | Output tokens returned by model providers |
cost | Accumulated model cost reported by the provider or billing adapter |
Alerting Rules
Critical (P0)
- Model CB open > 5m — Check model API status and API keys
- 2+ services with CB open — Cascading failure, check network/infra
- Bulkhead exhaustion > 10/min — Scale up or increase pool sizes
Warning (P1)
- Error rate > 5% over 5m — Check logs for failing service
- MCP fallback active > 10m — Check MCP server health
- Spans dropped > 100/min — Check OTel collector
SLO Definitions
| SLI | Target | Window |
|---|---|---|
| Agent completion success rate | 99.95% | 30-day rolling |
| Agent completion latency p99 | < 30s | 30-day rolling |
| Tool execution success rate | 99.9% | 30-day rolling |
| MCP availability | 99.9% | 30-day rolling |
Telemetry Lake Streaming
High-throughput agent swarms and multi-step workflows generate massive volumes of OpenTelemetry execution spans. Retaining these spans purely in ephemeral memory or standard log streams makes longitudinal analytics and deep diagnostic queries cost-prohibitive.
The isA_Agent_SDK provides a streaming columnar telemetry lake exporter (ParquetLakeExporter) that continuously buffers and flushes OpenTelemetry tracker spans into Snappy-compressed Apache Parquet micro-batches stored directly in S3 or MinIO object storage.
Architectural Flow
Parquet Schema Definition
The exporter strictly enforces a typed 27-column PyArrow schema (RUN_PARQUET_SCHEMA) capturing execution hierarchy, distributed OpenTelemetry trace context, model usage, costs, and arbitrary metadata:
| Column | Type | Description |
|---|---|---|
run_id | pa.string() | Canonical execution ID (run:<uuid>) |
trace_id | pa.string() | Platform trace identifier |
parent_run_id | pa.string() | Direct parent run ID for nested steps |
otel_trace_id | pa.string() | Distributed OpenTelemetry trace ID (32-char hex) |
otel_span_id | pa.string() | Distributed OpenTelemetry span ID (16-char hex) |
otel_parent_span_id | pa.string() | Parent span ID for causal linkage |
span_kind | pa.string() | Span kind (AGENT, CHAIN, LLM, TOOL, ROUTER) |
name | pa.string() | Step, agent, or tool name |
start_time | pa.timestamp("us", tz="UTC") | UTC start timestamp in microsecond precision |
end_time | pa.timestamp("us", tz="UTC") | UTC completion timestamp in microsecond precision |
duration_ms | pa.int64() | Total execution duration in milliseconds |
input_data | pa.string() | JSON-serialized input arguments |
output_data | pa.string() | JSON-serialized output payload |
model | pa.string() | Model identifier (e.g. gpt-4o, claude-3-5-sonnet) |
provider | pa.string() | Model provider (openai, anthropic, gemini) |
token_count_prompt | pa.int64() | Prompt token count |
token_count_completion | pa.int64() | Completion token count |
cost | pa.float64() | Calculated monetary cost in USD |
tool_name | pa.string() | Invoked tool name if span_kind is TOOL |
tool_arguments | pa.string() | JSON-serialized tool call arguments |
session_id | pa.string() | User conversation / session ID |
user_id | pa.string() | Invoking user ID |
organization_id | pa.string() | Tenant / organization identifier |
node_name | pa.string() | LangGraph / DAG node name |
status | pa.string() | Status enum (SUCCESS, ERROR, TIMEOUT, CANCELLED, RUNNING) |
error | pa.string() | Exception message or error stack trace |
metadata | pa.string() | JSON-serialized contextual metadata |
tags | pa.list_(pa.string()) | Array of searchable string tags |
Partitioning & Object Hierarchy
Micro-batches are partitioned along hourly temporal boundaries to support zero-copy analytical partition pruning via DuckDB or StarRocks:
s3://isa-data-lake/lake/telemetry/spans/
└── year=2026/
└── month=11/
└── day=30/
└── hour=06/
├── runs_e4e5b382-7ad2-4a0b-9dfb-12d8a5991873.parquet
└── runs_8d94e3c1-904c-4c6e-b391-76a147d34b12.parquetConfiguration & Data Loss Prevention
Configuration is managed via LakeExporterConfig or environment variables:
from isa_agent_sdk.tracker.lake.models import LakeExporterConfig
# Manual instantiation
config = LakeExporterConfig(
bucket_name="isa-data-lake",
prefix="lake/telemetry/spans",
endpoint="minio.internal:9000",
access_key="minioadmin",
secret_key="minioadmin",
secure=False,
compression="snappy",
batch_size=100,
)
# Or load from environment variables
config = LakeExporterConfig.from_env()Supported environment variables:
LAKE_BUCKET_NAME: Target S3/MinIO bucket (default:isa-data-lake)LAKE_PREFIX: Object key prefix (default:lake/telemetry/spans)MINIO_ENDPOINT: Host and port of the MinIO / S3 serviceMINIO_ACCESS_KEY&MINIO_SECRET_KEY: Storage authentication credentialsMINIO_SECURE:truefor TLS (HTTPS),falsefor HTTPLAKE_BATCH_SIZE: Number of buffered spans before triggering an automatic micro-batch flush (default:100)
Zero-Loss Buffer Retention
The ParquetLakeExporter.flush() method groups buffered runs by hour before writing to storage. If any partition write fails (e.g. transient network outage or storage throttling), failed runs are prepended back to the active memory buffer (self._buffer = failed_runs + self._buffer), ensuring no telemetry spans are lost.
Code Example: Streaming Spans
import asyncio
from datetime import datetime, timezone
from isa_agent_sdk.tracker.lake.exporter import ParquetLakeExporter
from isa_agent_sdk.tracker.models import Run, RunStatus, SpanKind
async def main():
exporter = ParquetLakeExporter()
# Buffer a completed run
run = Run(
run_id="run:a3f9e2b1-54c7-4389-915b-21d1d8ef3241",
trace_id="trace:9b2c4e...",
name="VectorSearchStep",
span_kind=SpanKind.TOOL,
tool_name="vector_similarity_search",
tool_arguments={"collection": "docs", "top_k": 5},
status=RunStatus.SUCCESS,
start_time=datetime.now(timezone.utc),
end_time=datetime.now(timezone.utc),
duration_ms=45,
)
exporter.buffer_run(run)
# Flush buffered runs into Parquet lake
results = await exporter.flush()
for res in results:
print(f"Batch {res.batch_id}: exported {res.run_count} runs ({res.bytes_written} bytes) to {res.storage_path}")
if __name__ == "__main__":
asyncio.run(main())