Skip to content

Commit cac9bd0

Browse files
committed
test(mcp-server): Refine span attributes and transport details
1 parent 03077f8 commit cac9bd0

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

packages/core/test/lib/mcp-server.test.ts

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ describe('wrapMcpServerWithSentry', () => {
224224
expect(tracingModule.startSpan).toHaveBeenCalledWith(
225225
expect.objectContaining({
226226
name: 'tools/call get-weather',
227-
op: 'mcp.server',
228227
forceTransaction: true,
229228
attributes: expect.objectContaining({
230229
// Required
@@ -244,7 +243,9 @@ describe('wrapMcpServerWithSentry', () => {
244243
'mcp.request.argument.location': '"Seattle, WA"',
245244
'mcp.request.argument.units': '"metric"',
246245
// Sentry-specific
246+
'sentry.op': 'mcp.server',
247247
'sentry.origin': 'auto.function.mcp_server',
248+
'sentry.source': 'route',
248249
}),
249250
}),
250251
expect.any(Function)
@@ -266,7 +267,7 @@ describe('wrapMcpServerWithSentry', () => {
266267
expect(tracingModule.startSpan).toHaveBeenCalledWith(
267268
expect.objectContaining({
268269
name: 'resources/read file:///docs/api.md',
269-
op: 'mcp.server',
270+
forceTransaction: true,
270271
attributes: expect.objectContaining({
271272
// Required
272273
'mcp.method.name': 'resources/read',
@@ -275,6 +276,16 @@ describe('wrapMcpServerWithSentry', () => {
275276
'mcp.request.id': 'req-2',
276277
// Recommended
277278
'mcp.session.id': 'test-session-123',
279+
// Transport attributes
280+
'mcp.transport': 'http',
281+
'network.transport': 'tcp',
282+
'network.protocol.version': '2.0',
283+
// Request arguments (JSON-stringified)
284+
'mcp.request.argument.uri': '"file:///docs/api.md"',
285+
// Sentry-specific
286+
'sentry.op': 'mcp.server',
287+
'sentry.origin': 'auto.function.mcp_server',
288+
'sentry.source': 'route',
278289
}),
279290
}),
280291
expect.any(Function)
@@ -296,7 +307,7 @@ describe('wrapMcpServerWithSentry', () => {
296307
expect(tracingModule.startSpan).toHaveBeenCalledWith(
297308
expect.objectContaining({
298309
name: 'prompts/get analyze-code',
299-
op: 'mcp.server',
310+
forceTransaction: true,
300311
attributes: expect.objectContaining({
301312
// Required
302313
'mcp.method.name': 'prompts/get',
@@ -305,6 +316,16 @@ describe('wrapMcpServerWithSentry', () => {
305316
'mcp.request.id': 'req-3',
306317
// Recommended
307318
'mcp.session.id': 'test-session-123',
319+
// Transport attributes
320+
'mcp.transport': 'http',
321+
'network.transport': 'tcp',
322+
'network.protocol.version': '2.0',
323+
// Request arguments (JSON-stringified)
324+
'mcp.request.argument.name': '"analyze-code"',
325+
// Sentry-specific
326+
'sentry.op': 'mcp.server',
327+
'sentry.origin': 'auto.function.mcp_server',
328+
'sentry.source': 'route',
308329
}),
309330
}),
310331
expect.any(Function)
@@ -325,16 +346,22 @@ describe('wrapMcpServerWithSentry', () => {
325346
expect(tracingModule.startSpan).toHaveBeenCalledWith(
326347
expect.objectContaining({
327348
name: 'notifications/tools/list_changed',
328-
op: 'mcp.server',
349+
forceTransaction: true,
329350
attributes: expect.objectContaining({
330351
// Required
331352
'mcp.method.name': 'notifications/tools/list_changed',
332353
// Recommended
333354
'mcp.session.id': 'test-session-123',
334355
// Notification-specific
335356
'mcp.notification.direction': 'client_to_server',
357+
// Transport attributes
358+
'mcp.transport': 'http',
359+
'network.transport': 'tcp',
360+
'network.protocol.version': '2.0',
336361
// Sentry-specific
362+
'sentry.op': 'mcp.server',
337363
'sentry.origin': 'auto.mcp.notification',
364+
'sentry.source': 'route',
338365
}),
339366
}),
340367
expect.any(Function)
@@ -362,11 +389,19 @@ describe('wrapMcpServerWithSentry', () => {
362389
expect(tracingModule.startSpan).toHaveBeenCalledWith(
363390
expect.objectContaining({
364391
name: 'tools/list',
365-
op: 'mcp.server',
392+
forceTransaction: true,
366393
attributes: expect.objectContaining({
367394
'mcp.method.name': 'tools/list',
368395
'mcp.request.id': 'req-4',
369396
'mcp.session.id': 'test-session-123',
397+
// Transport attributes
398+
'mcp.transport': 'http',
399+
'network.transport': 'tcp',
400+
'network.protocol.version': '2.0',
401+
// Sentry-specific
402+
'sentry.op': 'mcp.server',
403+
'sentry.origin': 'auto.function.mcp_server',
404+
'sentry.source': 'route',
370405
}),
371406
}),
372407
expect.any(Function)

0 commit comments

Comments
 (0)