Skip to content

refactor: migrate to observability v1 - #106

Merged
vreshch merged 1 commit into
masterfrom
feature/obs-v1
Sep 13, 2026
Merged

vreshch merged 1 commit into
masterfrom
feature/obs-v1

Conversation

@vreshch

@vreshch vreshch commented Sep 13, 2026

Copy link
Copy Markdown
Member

Moves landing onto @agentage/observability v1 - the module-singleton log, the /react reporter component, and the fetch-native health() factory.

Changes

  • @agentage/observability ^0.20.0 -> ^1.0.0 (packages/landing), lockfile regenerated with npm 10. The v1 tree drops @opentelemetry/sdk-node for an explicit tracer provider, so the lock shrinks by ~700 lines.
  • src/lib/logger.ts deleted. createLogger({ service }) is gone in v1 - log is a module singleton that takes its service from OTEL_SERVICE_NAME, which docker-compose.yml already sets to agentage-landing. instrumentation.ts was its only consumer.
  • instrumentation.ts now imports the singleton and keeps register re-exported from /next.
  • Browser reporter is <ErrorReporter /> from @agentage/observability/react instead of a hand-rolled useEffect + installErrorReporter. Same endpoint/service options, so the beacon target is unchanged.
  • /health uses health() (fetch-native handler factory) instead of healthResponse(). Identical envelope; verified locally.

The cross-origin collector is unchanged

Landing posts client errors cross-origin to the web backend at ${API_URL}/errors/report (prod: https://api.agentage.io/api/errors/report), built from the same NEXT_PUBLIC_SITE_FQDN build arg as the waitlist POST. <ErrorReporter /> is passed that exact same ERROR_REPORT_URL - this PR does not touch the endpoint, and web keeps that route alive for exactly this caller.

Worth knowing about the v1 browser lane: observeBrowser also mints a W3C trace id per user action and sends it as a traceparent header on same-origin fetch calls only. Cross-origin requests - including this beacon - are deliberately untouched, so the trace id rides the error payload rather than the collector request. Landing makes few same-origin fetches, so this is a no-op here.

Deviation from the v1 notes

onRequestError from /next is documented as the non-deprecated replacement, but in the published 1.0.0 it is still the factory onRequestError(log), not a ready value - dist/internal/patch/error-emitters.js exports function onRequestError(log). Re-exporting it directly would have handed Next a function that treats its err argument as a logger and silently swallows every server error. Kept the factory form, now fed the root singleton:

import { log } from '@agentage/observability';
import { onRequestError as kitOnRequestError } from '@agentage/observability/next';
export { register } from '@agentage/observability/next';
export const onRequestError = kitOnRequestError(log);

Worth a follow-up in the kit if a value form was the intent.

Verification

  • npm run verify green: type-check, lint, format:check, 70 tests in 8 files, production build (42 pages).
  • next dev booted from the worktree and driven with Playwright/Chromium:
    • <html data-obs-trace> = e9ebcabf0ab8139800b8d6dbd9fc3eda on load (valid 32-hex), and a fresh id after a history.pushState navigation - one id per user action, as designed.
    • A thrown browser error beaconed POST http://localhost:3001/api/errors/report (local API_URL), confirming the reporter is installed and the endpoint is byte-identical to before. ERR_CONNECTION_REFUSED on that POST is expected - no backend runs locally.
  • GET /health answers the standard envelope: {"success":true,"data":{"status":"ok","service":"unknown",...,"durationMs":0.1}}. service is unknown only because OTEL_SERVICE_NAME is unset in local dev; compose sets it in the deployed container.
  • Swept for removed exports (captureError, createLogger, withSpan, tracedFetch, installErrorReporter, healthResponse) - none remain. @agentage/shared does not touch the kit; it is the only other package in this repo.

⚠️ DEPLOY CAUTION

This repo deploys BOTH environments on push, and a green workflow run can still leave prod stale. After merge, do not trust the green check - commit-assert the deployed surface:

curl -s https://agentage.io/health   | jq -r .data.commit
curl -s https://docs.agentage.io/health | jq -r .data.commit

Both must equal the merge commit's short SHA. A frozen checkedAt or an old commit means prod did not roll; redeploy before calling it shipped.

Kit to ^1.0.0; drop the lib/logger.ts createLogger wrapper for the module
singleton, <ErrorReporter /> from /react, health() in the health route.
@github-actions

github-actions Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

✅ CI - Verify PASSED

Commit: 5534ed4f925f50cbab713e954c4015d11f654fd0 · Branch: feature/obs-v1

  • ✅ Type check
  • ✅ Lint
  • ✅ Format check
  • ✅ Unit tests + coverage
  • ✅ Build
  • ✅ Landing e2e

🔗 View workflow run

@vreshch
vreshch marked this pull request as ready for review September 13, 2026 21:45
@vreshch
vreshch merged commit 12d3f2e into master Sep 13, 2026
1 check passed
@vreshch
vreshch deleted the feature/obs-v1 branch September 13, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant