Task — engineering-spec@1

"RED metrics via cyberos-obs-sdk (axum middleware + cardinality guard)"

doneTASK-OBS-003
module obs · class product · priority p0 · created 2026-05-15 · shipped null
depends on TASK-OBS-001 · blocks TASK-OBS-007, TASK-OBS-005

TASK-OBS-003: RED metrics via cyberos-obs-sdk

Summary

Per-service RED (rate / errors / duration) metrics ship from services/shared/cyberos-obs-sdk/: red::record_request with status_class labels (DEC-152), thirteen standard histogram buckets (DEC-153), a 1000-series cardinality guard, and axum middleware (red_mw / RedState / TenantCtx) in layer.rsnot a #[red_instrument] proc-macro. Wired into auth, memory, and ai-gateway HTTP stacks; chat is not instrumented here (pinned image, no src). OTLP export is configured at service boot via init() when OBS_OTLP_ENDPOINT is set. Live end-to-end validation against a running TASK-OBS-001 collector stack remains a follow-on wiring step.

Problem

The original engineering-spec claimed crates/cyberos-obs-sdk/, a macros.rs proc-macro, an AST instrument_completeness_test, chat-service wiring, and standalone integration test files — none match the as-built tree. The body used ## §N grammar (FM-004). The live crate lives under services/shared/cyberos-obs-sdk/ with axum middleware (ADR-OBS-003-001) and inline module tests instead of separate tests/*.rs files.

Proposed Solution

Adopt the as-built layout:

Alternatives Considered

Success Metrics

Scope

In scope (as-built):

Out of scope / Non-Goals

Dependencies

depends_on: [TASK-OBS-001]. Soft: TASK-OBS-002 tenant proxy expects tenant_id on every metric series; TASK-OBS-007 alert rules query RED metrics.

1. Description (normative)

Acceptance criteria

Verification

cd services && cargo test -p cyberos-obs-sdk
cd services && cargo test -p cyberos-obs-sdk blocks_past_the_budget_and_is_idempotent_under_it
PathCovers
src/red.rs inline testsstatus_class, error_class, buckets, safe no-op before init
src/cardinality_guard.rs inline tests1000-combo cap, per-service isolation, label order
src/layer.rs inline testsTenantCtx defaults, middleware transparency
services/auth/src/handlers.rsauth RedState + red_mw wiring
services/memory/src/main.rsmemory RedState + red_mw wiring
services/ai-gateway/src/server/mod.rsai-gateway RedState + red_mw wiring

AI Authorship Disclosure


batch/9b-obs adopt — TASK-OBS-003 re-spec against as-built cyberos-obs-sdk middleware path.