File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed
packages/workers-shared/router-worker/src Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @cloudflare/workers-shared " : patch
3
+ ---
4
+
5
+ Adds metrics for time-to-dispatch to Router Worker
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ type Data = {
37
37
abuseMitigationBlocked ?: boolean ;
38
38
// double8 - User worker invocation denied due to free tier limiting
39
39
userWorkerFreeTierLimiting ?: boolean ;
40
+ // double9 - The time it takes for the request to be handed off the Asset Worker or user Worker in milliseconds
41
+ timeToDispatch ?: number ;
40
42
41
43
// -- Blobs --
42
44
// blob1 - Hostname of the request
@@ -96,6 +98,7 @@ export class Analytics {
96
98
this . data . staticRoutingDecision ?? STATIC_ROUTING_DECISION . NOT_PROVIDED , // double6
97
99
this . data . abuseMitigationBlocked ? 1 : 0 , // double7
98
100
this . data . userWorkerFreeTierLimiting ? 1 : 0 , // double8
101
+ this . data . timeToDispatch ?? - 1 , // double9
99
102
] ,
100
103
blobs : [
101
104
this . data . hostname ?. substring ( 0 , 256 ) , // blob1 - trim to 256 bytes
Original file line number Diff line number Diff line change @@ -130,6 +130,10 @@ export default {
130
130
}
131
131
}
132
132
133
+ analytics . setData ( {
134
+ timeToDispatch : performance . now ( ) - startTimeMs ,
135
+ } ) ;
136
+
133
137
if ( shouldBlockNonImageResponse ) {
134
138
const resp = await env . USER_WORKER . fetch ( maybeSecondRequest ) ;
135
139
const isImage = resp . headers
@@ -160,6 +164,9 @@ export default {
160
164
dispatchType : DISPATCH_TYPE . ASSETS ,
161
165
} ) ;
162
166
167
+ analytics . setData ( {
168
+ timeToDispatch : performance . now ( ) - startTimeMs ,
169
+ } ) ;
163
170
return env . ASSET_WORKER . fetch ( maybeSecondRequest ) ;
164
171
} ) ;
165
172
} ;
You can’t perform that action at this time.
0 commit comments