feat: vendor-neutral error-tracking adapter seam via logger sink#13
Open
zaxovaiko wants to merge 4 commits into
Open
feat: vendor-neutral error-tracking adapter seam via logger sink#13zaxovaiko wants to merge 4 commits into
zaxovaiko wants to merge 4 commits into
Conversation
Add the ERROR_TRACKING port + token so the runtime can report unhandled errors to a vendor, replaceable via an overlay (PostHog, Rollbar, ...). - new ErrorTrackingAdapter contract (fire-and-forget captureException) - NoopErrorTracker default; createSentryErrorTracker auto-binds when SENTRY_DSN is set, dynamically importing @sentry/node (optional dep, tracing gated on SENTRY_TRACES_SAMPLE_RATE), falling back to no-op if the SDK is absent so boot never crashes - capture at the three previously log-only seams: oRPC onError interceptor, event-subscriber failures, outbox-relay drops - docs/adapters/error-tracking.md + regenerated catalog
…sink
Core named a specific vendor (Sentry) in the engine - createApp imported
createSentryErrorTracker and auto-bound on SENTRY_DSN. That ships Sentry
code to every consumer, even a PostHog shop. Make the seam truly neutral.
- drop the Sentry reference impl + @sentry/node optional dep from core; the
engine imports no vendor SDK and has no SENTRY_DSN of its own
- report through the logger: createLogger's pino hook forwards any error-level
log carrying `err` to a process-wide error sink, so one logger.error({ err })
both logs and reports - no separate captureException at each site, and all
error logs are covered (not just three seams)
- createApp bridges the sink to whatever ERROR_TRACKING an overlay bound, after
plugins load; unbound -> error logs stay logs-only
- revert the createEventBus reporter param and the per-site capture calls
- vendors (Sentry, PostHog, ...) become consumer overlays - doc shows the
Sentry overlay recipe, mirroring the payment/KYC vendor overlays
d0bea38 to
7ffe93f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a vendor-neutral error-tracking “seam” that reports errors via the existing logger pipeline, so consumers can bind a vendor SDK (Sentry/PostHog/Rollbar/…) without core depending on any vendor.
Changes:
- Introduces an
ERROR_TRACKINGadapter contract (ErrorTrackingAdapter.captureException) and documents how to bind it via an overlay. - Adds a process-wide error sink (
error-sink.ts) and wirescreateLoggerto forwarderror-level logs containing{ err }into that sink (including request context metadata). - Bridges the sink to the bound adapter in
createAppafter plugins/configure, and updates the docs catalog.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Lockfile updated (includes @opentelemetry/api@1.9.1 optional peer entries). |
| packages/core/src/server/runtime/create-app.ts | Wires the process-wide error sink to the ERROR_TRACKING adapter when present. |
| packages/core/src/server/kernel/logger.ts | Adds a pino hook to mirror qualifying error logs to the error sink with request context. |
| packages/core/src/server/kernel/index.ts | Exports setErrorSink/reportError and the ErrorSink type. |
| packages/core/src/server/kernel/error-sink.ts | Implements the process-wide fire-and-forget error sink. |
| packages/core/src/server/kernel/tests/logger.test.ts | Adds unit tests for the logger → sink forwarding behavior. |
| packages/core/src/contracts/adapters/index.ts | Re-exports the error-tracking adapter types and token. |
| packages/core/src/contracts/adapters/error-tracking.ts | Adds the ErrorTrackingAdapter contract and ERROR_TRACKING token. |
| docs/catalog.json | Catalog entry for the new adapter seam. |
| docs/adapters/error-tracking.md | Documentation and example overlay binding (Sentry). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
94eb95a to
7ffe93f
Compare
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.
What
Adds a vendor-neutral
ERROR_TRACKINGadapter seam so the runtime can report unhandled errors to a vendor (Sentry, PostHog, Rollbar, ...), wired entirely through the logger. Core ships no vendor SDK - the vendor is a consumer overlay.contracts/adapters/error-tracking.ts):ErrorTrackingAdapterport +ERROR_TRACKINGtoken. Fire-and-forgetcaptureException(error, context?)- a reporter failure never breaks the calling path.server/kernel/error-sink.ts+logger.ts):createLogger's pino hook forwards any error-level log carryingerrto a process-wide error sink. Onelogger.error({ err })both logs and reports - no separatecaptureExceptioncall at each site, and every error log is covered rather than a hand-picked set of seams.createApp: after plugins load, the sink is wired to whateverERROR_TRACKINGan overlay bound. Unbound -> error logs stay logs-only; the engine imports no vendor SDK and has noSENTRY_DSNof its own.docs/adapters/error-tracking.md) show the Sentry overlay recipe, mirroring the payment/KYC vendor overlays. Regenerated catalog.Why
The platform had no error/crash reporting - unhandled errors only reached pino/stdout. This adds reporting while keeping core vendor-neutral: a consumer picks Sentry, PostHog, or anything else via an overlay, with zero vendor code shipped to shops that don't use it.
Acceptance
ERROR_TRACKING: everylogger.error({ err })is both logged and reported to the vendor.Verify
pnpm verifygreen (typecheck + 60 unit tests + lint + module-shape + boundaries); catalog/openapi no-drift. Rebased ondev, conflicts resolved, lockfile unchanged.