feat(CF-1354): Add withSentryTransaction to tool handlers
Wrap CallToolRequest handler with withSentryTransaction for per-tool tracing. Remove broken $(vault) DSN from .env. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2
.env
2
.env
@@ -11,7 +11,7 @@
|
|||||||
# - PostgreSQL integration for database error tracking
|
# - PostgreSQL integration for database error tracking
|
||||||
#
|
#
|
||||||
# Created: 2026-01-29
|
# Created: 2026-01-29
|
||||||
SENTRY_DSN=$(vault get sentry.dsn.mcp-servers)
|
# SENTRY_DSN provided via ~/.claude.json env (dotenv can't expand shell commands)
|
||||||
SENTRY_ENVIRONMENT=production
|
SENTRY_ENVIRONMENT=production
|
||||||
SENTRY_TRACE_SAMPLE_RATE=0.1
|
SENTRY_TRACE_SAMPLE_RATE=0.1
|
||||||
SENTRY_PROFILE_SAMPLE_RATE=0.01
|
SENTRY_PROFILE_SAMPLE_RATE=0.01
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const envPath = join(__dirname, '..', '.env');
|
|||||||
const result = dotenv.config({ path: envPath, override: true });
|
const result = dotenv.config({ path: envPath, override: true });
|
||||||
|
|
||||||
// Initialize Sentry for error tracking
|
// Initialize Sentry for error tracking
|
||||||
import { initSentry } from './sentry.js';
|
import { initSentry, withSentryTransaction } from './sentry.js';
|
||||||
initSentry(process.env.SENTRY_ENVIRONMENT || 'production');
|
initSentry(process.env.SENTRY_ENVIRONMENT || 'production');
|
||||||
|
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
@@ -99,6 +99,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|||||||
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||||
const { name, arguments: args } = request.params;
|
const { name, arguments: args } = request.params;
|
||||||
|
|
||||||
|
return withSentryTransaction(name, async () => {
|
||||||
try {
|
try {
|
||||||
let result: string;
|
let result: string;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
@@ -543,6 +544,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|||||||
isError: true,
|
isError: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Main entry point
|
// Main entry point
|
||||||
|
|||||||
Reference in New Issue
Block a user