@@ -9,6 +9,16 @@ test('@callable() methods work correctly with Sentry instrumentDurableObjectWith
99 ) ;
1010 } ) ;
1111
12+ // The greet() call goes over the websocket, so its storage spans land in a webSocketMessage
13+ // transaction. Filter for the one carrying our put span — control messages produce their own
14+ // webSocketMessage transactions without storage spans.
15+ const storageTransactionPromise = waitForTransaction ( 'cloudflare-agent' , transactionEvent => {
16+ return (
17+ transactionEvent . transaction === 'webSocketMessage' &&
18+ ( transactionEvent . spans ?? [ ] ) . some ( span => span . description === 'durable_object_storage_put' )
19+ ) ;
20+ } ) ;
21+
1222 await page . goto ( baseURL ! ) ;
1323
1424 await expect ( page . getByText ( 'Connected' ) ) . toBeVisible ( ) ;
@@ -32,24 +42,7 @@ test('@callable() methods work correctly with Sentry instrumentDurableObjectWith
3242 culture : { timezone : expect . any ( String ) } ,
3343 runtime : { name : 'cloudflare' } ,
3444 } ,
35- spans : expect . arrayContaining ( [
36- expect . objectContaining ( {
37- data : {
38- 'db.operation.name' : 'get' ,
39- 'db.system.name' : 'cloudflare.durable_object.storage' ,
40- 'sentry.op' : 'db' ,
41- 'sentry.origin' : 'auto.db.cloudflare.durable_object' ,
42- } ,
43- description : 'durable_object_storage_get' ,
44- op : 'db' ,
45- origin : 'auto.db.cloudflare.durable_object' ,
46- parent_span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
47- span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
48- start_timestamp : expect . any ( Number ) ,
49- timestamp : expect . any ( Number ) ,
50- trace_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
51- } ) ,
52- ] ) ,
45+ spans : [ ] ,
5346 start_timestamp : expect . any ( Number ) ,
5447 timestamp : expect . any ( Number ) ,
5548 transaction : 'GET /agents/my-agent/user-123' ,
@@ -72,4 +65,65 @@ test('@callable() methods work correctly with Sentry instrumentDurableObjectWith
7265 packages : expect . any ( Array ) ,
7366 } ,
7467 } ) ;
68+
69+ // greet() touches 6 storage keys: 2 user ops + 3 framework-internal keys (cf_, __ps_, /) that
70+ // must be filtered + 1 allowlisted cf_ key. Spans carry no key attribute, so filtering can only
71+ // be verified by count — exactly these 3 storage spans (in execution order) should survive, and
72+ // any framework-internal span leaking through shows up as an extra entry here.
73+ const storageTransaction = await storageTransactionPromise ;
74+
75+ const storageSpans = ( storageTransaction . spans ?? [ ] ) . filter (
76+ span => span . origin === 'auto.db.cloudflare.durable_object' ,
77+ ) ;
78+
79+ expect ( storageSpans ) . toEqual ( [
80+ expect . objectContaining ( {
81+ data : {
82+ 'db.operation.name' : 'put' ,
83+ 'db.system.name' : 'cloudflare.durable_object.storage' ,
84+ 'sentry.op' : 'db' ,
85+ 'sentry.origin' : 'auto.db.cloudflare.durable_object' ,
86+ } ,
87+ description : 'durable_object_storage_put' ,
88+ op : 'db' ,
89+ origin : 'auto.db.cloudflare.durable_object' ,
90+ parent_span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
91+ span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
92+ start_timestamp : expect . any ( Number ) ,
93+ timestamp : expect . any ( Number ) ,
94+ trace_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
95+ } ) ,
96+ expect . objectContaining ( {
97+ data : {
98+ 'db.operation.name' : 'get' ,
99+ 'db.system.name' : 'cloudflare.durable_object.storage' ,
100+ 'sentry.op' : 'db' ,
101+ 'sentry.origin' : 'auto.db.cloudflare.durable_object' ,
102+ } ,
103+ description : 'durable_object_storage_get' ,
104+ op : 'db' ,
105+ origin : 'auto.db.cloudflare.durable_object' ,
106+ parent_span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
107+ span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
108+ start_timestamp : expect . any ( Number ) ,
109+ timestamp : expect . any ( Number ) ,
110+ trace_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
111+ } ) ,
112+ expect . objectContaining ( {
113+ data : {
114+ 'db.operation.name' : 'get' ,
115+ 'db.system.name' : 'cloudflare.durable_object.storage' ,
116+ 'sentry.op' : 'db' ,
117+ 'sentry.origin' : 'auto.db.cloudflare.durable_object' ,
118+ } ,
119+ description : 'durable_object_storage_get' ,
120+ op : 'db' ,
121+ origin : 'auto.db.cloudflare.durable_object' ,
122+ parent_span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
123+ span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
124+ start_timestamp : expect . any ( Number ) ,
125+ timestamp : expect . any ( Number ) ,
126+ trace_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
127+ } ) ,
128+ ] ) ;
75129} ) ;
0 commit comments