Skip to content
Agentmart
Submit a tool

ai-observability

Observability for Bedrock AI calls: EMF metrics (BedrockTokensIn, BedrockTokensOut, BedrockLatencyMs), X-Ray subsegments per model call, cost dimension…

Skill by Cloud-Byte-Consulting

IndexedBSD-3-Clause
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/cloud-byte-consulting-ai-observability

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Observability for Bedrock AI calls: EMF metrics (BedrockTokensIn, BedrockTokensOut, BedrockLatencyMs), X-Ray subsegments per model call, cost dimension tracking by agent and model, daily budget monitoring, and structured logging for AI pipelines. Use when instrumenting Bedrock calls or debugging AI pipeline performance.

Use cases: data, finance, agent-building

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/ai-observability

What's inside

Skill name
ai-observability
Description
Observability for Bedrock AI calls: EMF metrics (BedrockTokensIn, BedrockTokensOut, BedrockLatencyMs), X-Ray subsegments per model call, cost dimension tracking by agent and model, daily budget monitoring, and structured logging for AI pipelines. Use when instrumenting Bedrock calls or debugging AI pipeline performance.
License
BSD-3-Clause
Instructions
171 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

<!-- Vendored from: platform-catalyst/skills/ai-observability/SKILL.md (BittahCriminal/platform-catalyst, BSD-3-Clause). Adapted for Catalyst: PLAN.md/CLAUDE.md/DECISIONS.md scrubbed; ADR-008->ADR-001, ADR-009->ADR-002. -->

# AI observability

## Role

You guide the instrumentation of Bedrock API calls in Catalyst with EMF metrics, X-Ray traces, and structured logs per `AGENTS.md` requirements and *Observability in the AI-Native Era* (Lipsig et al., Ch 1-3: observability pillars, Ch 7-8: AIOps).

## Instructions

### 1. Mandatory per-call EMF metrics (from AGENTS.md)

Every Bedrock Converse call MUST emit:

```python
from aws_lambda_powertools import Metrics
from aws_lambda_powertools.metrics import MetricUnit
import time
import structlog

logger = structlog.get_logger()
metrics = Metrics(namespace="Catalyst", service="pr-reviewer")

async def instrumented_converse(
    client: BedrockClient,
    model: BedrockModel,
    system_prompt: str,
    user_message: str,
    agent_name: str,
    **kwargs,
) -> dict:
    """Bedrock Converse with mandatory EMF metrics."""
    start = time.monotonic()

    try:
        response = await client.converse(model, system_prompt, user_message, **kwargs)
        latency_ms = (time.monotonic() - start) * 1000
        usage = extract_usage(response)

        # EMF metrics — dimensioned by Agent and Model
        metrics.add_dimension(name="Agent", value=agent_name)
        metrics.add_dimension(name="Model", value=model.value)
        metrics.add_metric(name="BedrockTokensIn", unit=MetricUnit.Count, value=usage["input_tokens"])
        metrics.add_metric(name="BedrockTokensOut", unit=MetricUnit.Count, value=usage["output_tokens"])
        metrics.add_metric(name="BedrockLatencyMs", unit=MetricUnit.Milliseconds, value=latency_ms)
        metrics.add_metric(name="BedrockCallSuccess", unit=MetricUnit.Count, value=1)

        # Structured log
        logger.info("bedrock_call_complete",
            agent=agent_name,
            model=model.value,
            input_tokens=usage["input_tokens"],
            output_tokens=usage["output_tokens"],
            latency_ms=round(latency_ms, 1),
        )

        return response

    except Exception as e:
        latency_ms = (time.monotonic() - start) * 1000
        metrics.add_dimension(name="Agent", value=agent_name)
        metrics.add_dimension(name="Model", value=model.value)
        metrics.add_metric(name="BedrockCallError", unit=MetricUnit.Count, value=1)
        metrics.add_metric(name="BedrockLatencyMs", unit=MetricUnit.Milliseconds, value=latency_ms)

        logger.error("bedrock_call_failed",
            agent=agent_name, model=model.value,
            error_type=type(e).__name__, error=str(e),
            latency_ms=round(latency_ms, 1),
        )
        raise
```

### 2. X-Ray subsegments

```python
from aws_xray_sdk.core import xray_recorder

@xray_recorder.capture_async("bedrock_converse")
async def traced_converse(client, model, system_prompt, user_message, agent_name):
    subsegment = xray_recorder.current_subsegment()
    subsegment.put_annotation("agent", agent_name)
    subsegment.put_annotation("model", model.value)

    response = await instrumented_converse(client, model, system_prompt, user_message, agent_name)

    usage = extract_usage(response)
    subsegment.put_metadata("token_usage", usage)

    return response
```

### 3. Cost tracking

Per *Observability in the AI-Native Era* Ch 7 (AI cost monitoring):

```python
# Approximate cost per 1K tokens (update when pricing changes)
COST_PER_1K_TOKENS = {
    BedrockModel.SONNET: {"input": 0.003, "output": 0.015},
    BedrockModel.HAIKU: {"input": 0.0008, "output": 0.004},
}

def estimate_cost(model: BedrockModel, usage: dict) -> float:
    """Estimate USD cost for a single Bedrock call."""
    rates = COST_PER_1K_TOKENS[model]
    input_cost = (usage["input_tokens"] / 1000) * rates["input"]
    output_cost = (usage["output_tokens"] / 1000) * rates["output"]
    return round(input_cost + output_cost, 6)
```

Emit cost as an EMF metric:
```python
metrics.add_metric(name="BedrockEstimatedCostUSD", unit=MetricUnit.Count, value=cost)
```

### 4. Daily budget monitoring

The `budget-exhausted` modifier label in the state machine (`docs/ADR/STATE-MACHINE.md`) fires when the daily token budget is exceeded:

From Cloud-Byte-Consulting/Catalyst, BSD-3-Clause.

More from Cloud-Byte-Consulting/Catalyst

Signals

Stars
0
Forks
0
Open issues
57
Last commit (this folder)
May 21, 2026 (5 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
BSD-3-Clause
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from Cloud-Byte-Consulting

Cite this page

ai-observability skill. Agent Mart. https://agentmart.dev/skills/cloud-byte-consulting-ai-observability (last updated 2026-10-24)