refactor: migrate to observability v1 - #106
Merged
Merged
Conversation
Kit to ^1.0.0; drop the lib/logger.ts createLogger wrapper for the module singleton, <ErrorReporter /> from /react, health() in the health route.
|
✅ CI - Verify PASSED Commit:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves landing onto
@agentage/observabilityv1 - the module-singletonlog, the/reactreporter component, and the fetch-nativehealth()factory.Changes
@agentage/observability^0.20.0->^1.0.0(packages/landing), lockfile regenerated with npm 10. The v1 tree drops@opentelemetry/sdk-nodefor an explicit tracer provider, so the lock shrinks by ~700 lines.src/lib/logger.tsdeleted.createLogger({ service })is gone in v1 -logis a module singleton that takes its service fromOTEL_SERVICE_NAME, whichdocker-compose.ymlalready sets toagentage-landing.instrumentation.tswas its only consumer.instrumentation.tsnow imports the singleton and keepsregisterre-exported from/next.<ErrorReporter />from@agentage/observability/reactinstead of a hand-rolleduseEffect+installErrorReporter. Sameendpoint/serviceoptions, so the beacon target is unchanged./healthuseshealth()(fetch-native handler factory) instead ofhealthResponse(). 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 sameNEXT_PUBLIC_SITE_FQDNbuild arg as the waitlist POST.<ErrorReporter />is passed that exact sameERROR_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:
observeBrowseralso mints a W3C trace id per user action and sends it as atraceparentheader on same-originfetchcalls 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
onRequestErrorfrom/nextis documented as the non-deprecated replacement, but in the published 1.0.0 it is still the factoryonRequestError(log), not a ready value -dist/internal/patch/error-emitters.jsexportsfunction onRequestError(log). Re-exporting it directly would have handed Next a function that treats itserrargument as a logger and silently swallows every server error. Kept the factory form, now fed the root singleton:Worth a follow-up in the kit if a value form was the intent.
Verification
npm run verifygreen: type-check, lint, format:check, 70 tests in 8 files, production build (42 pages).next devbooted from the worktree and driven with Playwright/Chromium:<html data-obs-trace>=e9ebcabf0ab8139800b8d6dbd9fc3edaon load (valid 32-hex), and a fresh id after ahistory.pushStatenavigation - one id per user action, as designed.POST http://localhost:3001/api/errors/report(localAPI_URL), confirming the reporter is installed and the endpoint is byte-identical to before.ERR_CONNECTION_REFUSEDon that POST is expected - no backend runs locally.GET /healthanswers the standard envelope:{"success":true,"data":{"status":"ok","service":"unknown",...,"durationMs":0.1}}.serviceisunknownonly becauseOTEL_SERVICE_NAMEis unset in local dev; compose sets it in the deployed container.captureError,createLogger,withSpan,tracedFetch,installErrorReporter,healthResponse) - none remain.@agentage/shareddoes not touch the kit; it is the only other package in this repo.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:
Both must equal the merge commit's short SHA. A frozen
checkedAtor an oldcommitmeans prod did not roll; redeploy before calling it shipped.