@@ -87,6 +87,9 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
87
87
Ok ( resp)
88
88
}
89
89
90
+ let metrics = extension ! ( req, Metrics ) . clone ( ) ;
91
+ let mut rendering_time = RenderingTimesRecorder :: new ( & metrics. rustdoc_redirect_rendering_times ) ;
92
+
90
93
// this unwrap is safe because iron urls are always able to use `path_segments`
91
94
// i'm using this instead of `req.url.path()` to avoid allocating the Vec, and also to avoid
92
95
// keeping the borrow alive into the return statement
@@ -102,8 +105,10 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
102
105
// redirecting to the crate root page
103
106
if req. url . as_ref ( ) . path_segments ( ) . unwrap ( ) . count ( ) > 2 {
104
107
// this URL is actually from a crate-internal path, serve it there instead
108
+ rendering_time. step ( "serve JS for crate" ) ;
105
109
return rustdoc_html_server_handler ( req) ;
106
110
} else {
111
+ rendering_time. step ( "serve JS" ) ;
107
112
let storage = extension ! ( req, Storage ) ;
108
113
let config = extension ! ( req, Config ) ;
109
114
@@ -124,6 +129,7 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
124
129
{
125
130
// route .ico files into their dedicated handler so that docs.rs's favicon is always
126
131
// displayed
132
+ rendering_time. step ( "serve ICO" ) ;
127
133
return super :: statics:: ico_handler ( req) ;
128
134
}
129
135
@@ -141,6 +147,7 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
141
147
142
148
// it doesn't matter if the version that was given was exact or not, since we're redirecting
143
149
// anyway
150
+ rendering_time. step ( "match version" ) ;
144
151
let v = match_version ( & mut conn, & crate_name, req_version) ?;
145
152
if let Some ( new_name) = v. corrected_name {
146
153
// `match_version` checked against -/_ typos, so if we have a name here we should
@@ -151,6 +158,7 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
151
158
152
159
// get target name and whether it has docs
153
160
// FIXME: This is a bit inefficient but allowing us to use less code in general
161
+ rendering_time. step ( "fetch release doc status" ) ;
154
162
let ( target_name, has_docs) : ( String , bool ) = {
155
163
let rows = ctry ! (
156
164
req,
@@ -170,8 +178,10 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
170
178
}
171
179
172
180
if has_docs {
181
+ rendering_time. step ( "redirect to doc" ) ;
173
182
redirect_to_doc ( req, & crate_name, & version, target, & target_name)
174
183
} else {
184
+ rendering_time. step ( "redirect to crate" ) ;
175
185
redirect_to_crate ( req, & crate_name, & version)
176
186
}
177
187
}
0 commit comments