diff --git a/eden/mononoke/git_server/src/middleware/response/mod.rs b/eden/mononoke/git_server/src/middleware/response/mod.rs index c7a14fa342546..e66b4786f48a8 100644 --- a/eden/mononoke/git_server/src/middleware/response/mod.rs +++ b/eden/mononoke/git_server/src/middleware/response/mod.rs @@ -6,4 +6,8 @@ */ pub mod content_type; +#[cfg(fbcode_build)] +mod facebook; pub mod ods; +#[cfg(not(fbcode_build))] +mod oss; diff --git a/eden/mononoke/git_server/src/middleware/response/ods.rs b/eden/mononoke/git_server/src/middleware/response/ods.rs index 5693b589b0de4..961da77180a7b 100644 --- a/eden/mononoke/git_server/src/middleware/response/ods.rs +++ b/eden/mononoke/git_server/src/middleware/response/ods.rs @@ -17,6 +17,10 @@ use hyper::StatusCode; use permission_checker::MononokeIdentitySetExt; use stats::prelude::*; +#[cfg(fbcode_build)] +use crate::middleware::response::facebook::log_ods3; +#[cfg(not(fbcode_build))] +use crate::middleware::response::oss::log_ods3; use crate::model::GitMethod; use crate::model::GitMethodInfo; @@ -47,6 +51,7 @@ fn log_stats(state: &mut State, status: StatusCode) -> Option<()> { let method_info = state.try_borrow::()?; let method = method_info.method.clone(); let repo = method_info.repo.clone(); + let request_load = RequestLoad::try_borrow_from(state).map(|r| r.0 as f64); let callbacks = state.try_borrow_mut::()?; @@ -75,8 +80,10 @@ fn log_stats(state: &mut State, status: StatusCode) -> Option<()> { } if let Some(response_bytes_sent) = info.meta.as_ref().map(|m| m.body().bytes_sent) { - STATS::response_bytes_sent.add_value(response_bytes_sent as i64, (method,)) + STATS::response_bytes_sent.add_value(response_bytes_sent as i64, (method.clone(),)) } + + log_ods3(info, &status, method, repo, request_load); }); if let Some(request_load) = RequestLoad::try_borrow_from(state) { diff --git a/eden/mononoke/git_server/src/middleware/response/oss/mod.rs b/eden/mononoke/git_server/src/middleware/response/oss/mod.rs new file mode 100644 index 0000000000000..539d9aa76c527 --- /dev/null +++ b/eden/mononoke/git_server/src/middleware/response/oss/mod.rs @@ -0,0 +1,18 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This software may be used and distributed according to the terms of the + * GNU General Public License version 2. + */ + +use gotham_ext::middleware::post_request::PostResponseInfo; +use hyper::StatusCode; + +pub fn log_ods3( + _info: &PostResponseInfo, + _status: &StatusCode, + _method: String, + _repo: String, + _request_load: Option, +) { +}