Skip to Content

Observability

The Agent SDK has a 3-layer observability architecture:

LayerToolScope
ProxyPrometheus via isa_common.metricsHTTP gateway metrics (latency, error rates, tokens)
AgentOpenTelemetry via TracingManagerService call spans (model, tool, memory, session)
TrainingAgent LightningRL 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.0

Service 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

MetricDescription
cb_state{service}0=closed, 1=open, 2=half_open
cb_failure_count{service}Total failures
cb_success_count{service}Total successes

Bulkhead

MetricDescription
bulkhead_active{pool}Currently occupied slots
bulkhead_queued{pool}Requests waiting
bulkhead_total_exhausted{pool}Timeout exhaustions

MCP Fallback

MetricDescription
mcp_fallback_active1 if fallback mode
mcp_fallback_activation_countTimes fallback activated
mcp_fallback_cached_toolsCached tool schemas

Model Usage

Recent SDK counters expose model-call volume, token usage, and cost attribution for agent runs.

MetricDescription
model_callsNumber of model calls issued by the agent runtime
tokens_inInput tokens sent to model providers
tokens_outOutput tokens returned by model providers
costAccumulated 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

SLITargetWindow
Agent completion success rate99.95%30-day rolling
Agent completion latency p99< 30s30-day rolling
Tool execution success rate99.9%30-day rolling
MCP availability99.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:

ColumnTypeDescription
run_idpa.string()Canonical execution ID (run:<uuid>)
trace_idpa.string()Platform trace identifier
parent_run_idpa.string()Direct parent run ID for nested steps
otel_trace_idpa.string()Distributed OpenTelemetry trace ID (32-char hex)
otel_span_idpa.string()Distributed OpenTelemetry span ID (16-char hex)
otel_parent_span_idpa.string()Parent span ID for causal linkage
span_kindpa.string()Span kind (AGENT, CHAIN, LLM, TOOL, ROUTER)
namepa.string()Step, agent, or tool name
start_timepa.timestamp("us", tz="UTC")UTC start timestamp in microsecond precision
end_timepa.timestamp("us", tz="UTC")UTC completion timestamp in microsecond precision
duration_mspa.int64()Total execution duration in milliseconds
input_datapa.string()JSON-serialized input arguments
output_datapa.string()JSON-serialized output payload
modelpa.string()Model identifier (e.g. gpt-4o, claude-3-5-sonnet)
providerpa.string()Model provider (openai, anthropic, gemini)
token_count_promptpa.int64()Prompt token count
token_count_completionpa.int64()Completion token count
costpa.float64()Calculated monetary cost in USD
tool_namepa.string()Invoked tool name if span_kind is TOOL
tool_argumentspa.string()JSON-serialized tool call arguments
session_idpa.string()User conversation / session ID
user_idpa.string()Invoking user ID
organization_idpa.string()Tenant / organization identifier
node_namepa.string()LangGraph / DAG node name
statuspa.string()Status enum (SUCCESS, ERROR, TIMEOUT, CANCELLED, RUNNING)
errorpa.string()Exception message or error stack trace
metadatapa.string()JSON-serialized contextual metadata
tagspa.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.parquet

Configuration & 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 service
  • MINIO_ACCESS_KEY & MINIO_SECRET_KEY: Storage authentication credentials
  • MINIO_SECURE: true for TLS (HTTPS), false for HTTP
  • LAKE_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())
Was this page helpful?