Repository navigation
packages telemetry
Scope. Optional OpenTelemetry for the golden-path Next.js → Hono → Prisma chain. Not SentraBot/Kediri/Avery observability.
OpenTelemetry Node SDK (OTLP HTTP traces, HTTP + Prisma instrumentation) and a Hono middleware that opens a root span per request. Server-only — never import from browser code.
| File | Purpose |
|---|---|
packages/telemetry/src/index.ts |
Barrel: config loader, middleware, init/shutdown |
packages/telemetry/src/config.ts |
loadTelemetryConfig from env with safe defaults |
packages/telemetry/src/instrumentation.ts |
initTelemetry / shutdownTelemetry (Node SDK) |
packages/telemetry/src/hono-middleware.ts |
telemetryMiddleware — one root span per request |
packages/telemetry/package.json |
OpenTelemetry SDK, HTTP + Prisma instrumentation, Hono |
loadTelemetryConfig(env, overrides) resolves:
-
serviceName— fromOTEL_SERVICE_NAME, default"safrs-app". -
otlpEndpoint— fromOTEL_EXPORTER_OTLP_ENDPOINT, defaulthttp://localhost:4318/v1/traces. -
disabled— true whenOTEL_SDK_DISABLEDis"1"or"true".
No credentials are accepted; the endpoint is a plain HTTP URL. The exporter is disabled unless OTEL_SDK_DISABLED is unset — production traffic is not routed to a collector without an approved R2 change.
initTelemetry(config) builds a NodeSDK (OTLP HTTP trace exporter, HttpInstrumentation, PrismaInstrumentation), calls sdk.start(), and caches the singleton. Repeated calls return the existing SDK; when disabled it returns null so callers can short-circuit. shutdownTelemetry() flushes and stops the SDK (for SIGTERM / server shutdown).
Rule: initTelemetry must run before the app imports any instrumented path (HTTP client/server, Prisma) — at the top of the Next.js instrumentation.ts.
telemetryMiddleware() starts a root span labelled "METHOD /path" with semantic-convention attributes for HTTP method, route, and full URL, then sets safrs.correlation_id from the Hono Variables (set by @safrs/api) so a request trace can be correlated with the error envelope. It records the response status and ends the span in a finally. No payload data, credentials, or raw SQL parameter values are ever recorded — spans carry only operation names and safe metadata.
flowchart LR
R["incoming request"] --> A["@safrs/api<br/>correlation middleware"]
A --> T["telemetryMiddleware<br/>root span + correlation_id"]
T --> DB["PrismaInstrumentation<br/>query spans"]
T --> COL["OTLP exporter<br/>localhost:4318"]
COL --> JAEGER["Jaeger all-in-one<br/>compose.telemetry.yaml"]
-
@safrs/apiappliestelemetryMiddleware()to every API route (packages/api/src/app.ts). -
PrismaInstrumentationis started by@safrs/telemetry'sinitTelemetry, invoked fromprojects/internal/golden-path/apps/web/src/instrumentation.ts— not frompackages/database/src/client.ts, which only builds the Prisma client. -
@safrs/webinitializes telemetry at startup and consumes the package server-side. -
Local collector:
docker compose -f compose.telemetry.yaml up -d jaegerstarts the Jaeger UI (localhost:16686).
pnpm --filter @safrs/telemetry test
pnpm --filter @safrs/telemetry typecheck
pnpm --filter @safrs/telemetry lint- API — applies the request middleware
- Database — Prisma query instrumentation
- Shared packages
SAFRS — the Sentra Agent-First Repository Standard — defines how a software repository should be structured, governed, and enforced when autonomous Artificial Intelligence agents perform a substantial share of engineering work by Sentra Artificial Intelligence.
SAFRS v1.1 addresses that problem through five coupled mechanisms:
- a six-layer repository architecture from Trust Boundary to Human Authority;
- a role-based permission model in which capability never implies trust;
- a four-tier risk model with cumulative mandatory controls;
- a multi-agent execution protocol with explicit task states and one mutation owner per bounded scope;
- a knowledge governance model that distinguishes current architecture, historical decisions, execution plans, Git history, and running code.
Built in Indonesia as part of the Sentra Artificial Intelligence ecosystem.
Sentra Artificial Intelligence · Source Repository · Official Website
Dr Ferdi Iskandar — Creator & Maintainer
LinkedIn ·
ORCID ·
Hugging Face ·
Kaggle ·
Medium ·
Substack ·
X ·
Threads
MyPrompt · Sentra Artificial Intelligence · Indonesia
- SentraBot
- Kediri History
- Academic Smartboard
- Avery
- Portfolio Dr. Novia
- Golden Path (legacy demonstrator)
- Control Center
- Capsule template
- Risk model (R0–R3)
- Agent roles and permissions
- Capsule sovereignty
- Multi-agent protocol
- Document lifecycle
- Sensitive paths
- Verification integrity
Lore — how this repository grew
- Schemas (
@safrs/schemas) - Environment (
@safrs/env) - Database (
@safrs/database) - API (
@safrs/api) - UI (
@safrs/ui) - Telemetry (
@safrs/telemetry) - Token (
@sentra/token) - Config (
@safrs/config) - Auth (
packages/auth)
- SAFRS governance checkers
- SAFRS Automation Control Plane
- Gaffer Runtime
- Doctor
- Project wizard
- project-standalone
- Capabilities
- Codegen
- Deps-graph
- Status CLI
- Task CLI