Skip to content

feat(server): add sentry error and performance monitoring - #11

Merged
RaplesWojtyla merged 3 commits into
mainfrom
feat/sentry-monitoring
Aug 8, 2026
Merged

RaplesWojtyla merged 3 commits into
mainfrom
feat/sentry-monitoring

Conversation

@RaplesWojtyla

@RaplesWojtyla RaplesWojtyla commented Aug 8, 2026 •

Copy link
Copy Markdown
Owner

New Features

  • Added enhanced server monitoring for request tracing, structured logs, and error reporting.
  • Added a diagnostic endpoint for verifying error monitoring and metrics collection.
  • Session activity now includes clearer informational and warning events.

Bug Fixes

  • Improved visibility into failed requests, validation issues, missing sessions, and unexpected server errors while preserving existing error responses.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added enhanced server monitoring for request tracing, structured logs, and error reporting.
    • Added a diagnostic endpoint for verifying error monitoring and metrics collection.
    • Session activity now includes clearer informational and warning events.
  • Bug Fixes

    • Improved visibility into failed requests, validation issues, missing sessions, and unexpected server errors while preserving existing error responses.

Walkthrough

The server adds Sentry runtime integrations, middleware, structured error logs, a debug endpoint, and instrumentation for session route events.

Changes

Server observability

Layer / File(s) Summary
Sentry integration and error handling
packages/server/package.json, packages/server/src/index.ts
The server adds Bun and Hono Sentry dependencies, configures Sentry middleware, adds /debug-sentry, and logs handled and unhandled errors with structured data.
Session route instrumentation
packages/server/src/routes/session.ts
Session routes log validation failures, session counts, missing sessions, and successful session creation events.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Poem

I’m a rabbit with logs in my pack,
Sentry watches each route’s track.
Errors hop, metrics grow,
Session events now show.
Debug carrots help trace the stack!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided, so the description check cannot confirm that it relates to the changeset. Add a brief description of the Sentry dependencies, middleware, debug endpoint, and session-route logging changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the added Sentry error and performance monitoring changes.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/sentry-monitoring

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (2)
packages/server/src/index.ts (2)

12-12: 🚀 Performance & Scalability | 🔵 Trivial

Make trace sampling production-safe.

tracesSampleRate: 1.0 records every request for all deployments because the Sentry middleware has no environment branch. Use a lower production default, such as 0.01, and keep 1.0 only behind an explicit diagnostics flag.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/server/src/index.ts` at line 12, Update the Sentry configuration
around tracesSampleRate so production uses a lower default such as 0.01 instead
of 1.0. Preserve 1.0 only when an explicit diagnostics flag is enabled, and
ensure the environment branching applies consistently to all deployments.

11-11: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Use an environment-specific Sentry DSN.

The server always initialises Sentry with the same DSN, so local or test environments send data to the production project if left enabled. Read SENTRY_DSN from deployment configuration and skip Sentry setup when the DSN is absent.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/server/src/index.ts` at line 11, Update the Sentry initialization in
the server entrypoint to read the DSN from the SENTRY_DSN environment
configuration instead of using a hardcoded production value, and skip setup
entirely when SENTRY_DSN is absent. Preserve the existing initialization
behavior when a DSN is provided.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/server/package.json`:
- Around line 15-16: Synchronize the Sentry SDK versions in the package
dependencies by pinning both `@sentry/bun` and `@sentry/hono` to exactly 10.69.0, or
add an equivalent workspace override if the package must remain on that version.

In `@packages/server/src/index.ts`:
- Around line 17-24: Protect the /debug-sentry route registration in the server
bootstrap by requiring an explicit enable flag and the existing internal
authentication or network policy, or exclude the route from production entirely.
Ensure unauthorised callers cannot execute the logger.info, metrics.count, or
deliberate error throw inside the handler.
- Line 13: Configure the Sentry logging setup in packages/server/src/index.ts at
lines 13-13 with an approved environment-controlled beforeSendLog
allowlist/redaction policy before enabling logs. In
packages/server/src/routes/session.ts lines 64-67, remove the fabricated userId
and log only a short pseudonymous correlation ID; in lines 97-100, exclude the
user-controlled title and emit only approved safe identifiers or metadata.
- Around line 44-48: Change the unhandled server failure log in the surrounding
error handler from logger.warn to logger.error, preserving the existing safe
metadata payload of message, path, and method. Do not add Sentry-specific log
data because the Hono middleware already captures context.error.

---

Nitpick comments:
In `@packages/server/src/index.ts`:
- Line 12: Update the Sentry configuration around tracesSampleRate so production
uses a lower default such as 0.01 instead of 1.0. Preserve 1.0 only when an
explicit diagnostics flag is enabled, and ensure the environment branching
applies consistently to all deployments.
- Line 11: Update the Sentry initialization in the server entrypoint to read the
DSN from the SENTRY_DSN environment configuration instead of using a hardcoded
production value, and skip setup entirely when SENTRY_DSN is absent. Preserve
the existing initialization behavior when a DSN is provided.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e6e4e6fb-7045-447c-9819-2d83a17e2fdd

📥 Commits

Reviewing files that changed from the base of the PR and between a34e82e and 39a6f08.

📒 Files selected for processing (3)
  • packages/server/package.json
  • packages/server/src/index.ts
  • packages/server/src/routes/session.ts

Comment thread packages/server/package.json
Comment thread packages/server/src/index.ts
Comment thread packages/server/src/index.ts
Comment thread packages/server/src/index.ts Outdated
@RaplesWojtyla
RaplesWojtyla merged commit feaf1f1 into main Aug 8, 2026
2 checks passed
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