feat(CF-2136): Add Sentry structured logging support

Enable Sentry.logger API (enableLogs, beforeSendLog) and add
logInfo/logWarn/logError helpers. Bump @sentry/node ^9.47.1 → ^10.39.0,
@sentry/profiling-node → ^10.39.0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Gick
2026-03-04 10:22:08 +02:00
parent 9dae176fc2
commit 3613e2aa52
3 changed files with 416 additions and 1142 deletions

1537
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -12,8 +12,8 @@
}, },
"dependencies": { "dependencies": {
"@modelcontextprotocol/sdk": "^1.0.4", "@modelcontextprotocol/sdk": "^1.0.4",
"@sentry/node": "^9.47.1", "@sentry/node": "^10.39.0",
"@sentry/profiling-node": "^10.37.0", "@sentry/profiling-node": "^10.39.0",
"dotenv": "^17.2.3", "dotenv": "^17.2.3",
"pg": "^8.11.3" "pg": "^8.11.3"
}, },

View File

@@ -70,6 +70,11 @@ export function initSentry(environment: string = "development"): void {
return event; return event;
}, },
enableLogs: true,
beforeSendLog(log) {
if (log.level === "debug") return null;
return log;
},
maxBreadcrumbs: 30, maxBreadcrumbs: 30,
attachStacktrace: true, attachStacktrace: true,
release: process.env.APP_VERSION || "unknown", release: process.env.APP_VERSION || "unknown",
@@ -81,6 +86,18 @@ export function initSentry(environment: string = "development"): void {
); );
} }
export function logInfo(msg: string, data?: Record<string, unknown>): void {
Sentry.logger.info(msg, data);
}
export function logWarn(msg: string, data?: Record<string, unknown>): void {
Sentry.logger.warn(msg, data);
}
export function logError(msg: string, data?: Record<string, unknown>): void {
Sentry.logger.error(msg, data);
}
/** /**
* Wrap MCP tool handler with Sentry transaction tracking. * Wrap MCP tool handler with Sentry transaction tracking.
* *