Skip to content

Commit e9f300a

Browse files
sypharJoshua Nelson
authored and
Joshua Nelson
committed
add metrics for "I'm feeling lucky" searches
1 parent fe4cdc3 commit e9f300a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/metrics/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ metrics! {
7171

7272
/// The number of attempted files that failed due to a memory limit
7373
pub(crate) html_rewrite_ooms: IntCounter,
74+
75+
/// the number of "I'm feeling lucky" searches for crates
76+
pub(crate) im_feeling_lucky_searches: IntCounter,
7477
}
7578

7679
// The Rust prometheus library treats the namespace as the "prefix" of the metric name: a

src/web/releases.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,9 @@ fn redirect_to_random_crate(req: &Request, conn: &mut PoolClient) -> IronResult<
550550
let mut resp = Response::with((status::Found, Redirect(url)));
551551
resp.headers.set(Expires(HttpDate(time::now())));
552552

553+
let metrics = extension!(req, crate::Metrics).clone();
554+
metrics.im_feeling_lucky_searches.inc();
555+
553556
log::debug!("finished random crate search on iteration {}", i);
554557
return Ok(resp);
555558
} else {

0 commit comments

Comments
 (0)