Skip to content

Commit

Permalink
Boilerplate for logging to ODS3
Browse files Browse the repository at this point in the history
Reviewed By: RajivTS, clara-9

Differential Revision: D68833614

fbshipit-source-id: cdcefdfdaaad11351d23f376a732b4b5c40f6f34
  • Loading branch information
andreacampi authored and facebook-github-bot committed Jan 29, 2025
1 parent 64a3817 commit 400b59b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions eden/mononoke/git_server/src/middleware/response/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
*/

pub mod content_type;
#[cfg(fbcode_build)]
mod facebook;
pub mod ods;
#[cfg(not(fbcode_build))]
mod oss;
9 changes: 8 additions & 1 deletion eden/mononoke/git_server/src/middleware/response/ods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -47,6 +51,7 @@ fn log_stats(state: &mut State, status: StatusCode) -> Option<()> {
let method_info = state.try_borrow::<GitMethodInfo>()?;
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::<PostResponseCallbacks>()?;

Expand Down Expand Up @@ -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) {
Expand Down
18 changes: 18 additions & 0 deletions eden/mononoke/git_server/src/middleware/response/oss/mod.rs
Original file line number Diff line number Diff line change
@@ -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<f64>,
) {
}

0 comments on commit 400b59b

Please sign in to comment.