@@ -49,7 +49,8 @@ test('sends spans for MCP tool calls', async ({ baseURL }) => {
4949 typeof mcpEvent === 'string' ||
5050 ! ( 'contexts' in mcpEvent ) ||
5151 typeof requestEvent === 'string' ||
52- ! ( 'contexts' in requestEvent )
52+ ! ( 'contexts' in requestEvent ) ||
53+ ! ( 'spans' in requestEvent )
5354 ) {
5455 throw new Error ( "Events don't have contexts" ) ;
5556 }
@@ -71,21 +72,55 @@ test('sends spans for MCP tool calls', async ({ baseURL }) => {
7172 'url.port' : '38787' ,
7273 'url.scheme' : 'http:' ,
7374 'server.address' : 'localhost' ,
74- 'http.request.body.size' : 120 ,
7575 'user_agent.original' : 'node' ,
76- 'http.request.header.content_type' : 'application/json' ,
7776 'network.protocol.name' : 'HTTP/1.1' ,
78- 'mcp.server.extra' : ' /|\ ^._.^ /|\ ' ,
79- 'http.response.status_code' : 200 ,
8077 } ) ,
8178 op : 'http.server' ,
82- status : 'ok' ,
8379 origin : 'auto.http.cloudflare' ,
8480 } ) ;
8581
82+ expect ( requestEvent . spans ) . toEqual ( [
83+ {
84+ data : {
85+ 'sentry.origin' : 'auto.http.cloudflare' ,
86+ 'sentry.op' : 'http.server' ,
87+ 'sentry.source' : 'url' ,
88+ 'http.request.method' : 'POST' ,
89+ 'url.path' : '/mcp' ,
90+ 'url.full' : 'http://localhost:38787/mcp' ,
91+ 'url.port' : '38787' ,
92+ 'url.scheme' : 'http:' ,
93+ 'server.address' : 'localhost' ,
94+ 'http.request.body.size' : 120 ,
95+ 'user_agent.original' : 'node' ,
96+ 'http.request.header.accept' : 'application/json, text/event-stream' ,
97+ 'http.request.header.accept_encoding' : 'br, gzip' ,
98+ 'http.request.header.accept_language' : '*' ,
99+ 'http.request.header.cf_connecting_ip' : '::1' ,
100+ 'http.request.header.content_length' : '120' ,
101+ 'http.request.header.content_type' : 'application/json' ,
102+ 'http.request.header.host' : 'localhost:38787' ,
103+ 'http.request.header.sec_fetch_mode' : 'cors' ,
104+ 'http.request.header.user_agent' : 'node' ,
105+ 'network.protocol.name' : 'HTTP/1.1' ,
106+ 'mcp.server.extra' : ' /|\ ^._.^ /|\ ' ,
107+ 'http.response.status_code' : 200 ,
108+ } ,
109+ description : 'fetch' ,
110+ op : 'http.server' ,
111+ parent_span_id : expect . any ( String ) ,
112+ span_id : expect . any ( String ) ,
113+ start_timestamp : expect . any ( Number ) ,
114+ status : 'ok' ,
115+ timestamp : expect . any ( Number ) ,
116+ trace_id : expect . any ( String ) ,
117+ origin : 'auto.http.cloudflare' ,
118+ } ,
119+ ] ) ;
120+
86121 expect ( mcpEvent . contexts ?. trace ) . toEqual ( {
87122 trace_id : expect . any ( String ) ,
88- parent_span_id : requestEvent . contexts ?. trace ?. span_id ,
123+ parent_span_id : requestEvent . spans ?. [ 0 ] ?. span_id ,
89124 span_id : expect . any ( String ) ,
90125 op : 'mcp.server' ,
91126 origin : 'auto.function.mcp_server' ,
0 commit comments