Skip to content

Commit

Permalink
Initial structure for ODS3 logging for Mononoke Server
Browse files Browse the repository at this point in the history
Summary: :)

Reviewed By: andreacampi

Differential Revision: D68830617

fbshipit-source-id: 17e3251c6e3ee5721276194dc2dc574569358a0c
  • Loading branch information
RajivTS authored and facebook-github-bot committed Jan 29, 2025
1 parent 078e639 commit 8dcb0a1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions eden/mononoke/edenapi_service/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
* GNU General Public License version 2.
*/

#[cfg(fbcode_build)]
mod facebook;
pub mod ods;
#[cfg(not(fbcode_build))]
mod oss;
pub mod rate_limiter;
pub mod request_dumper;

Expand Down
9 changes: 7 additions & 2 deletions eden/mononoke/edenapi_service/src/middleware/ods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ use stats::prelude::*;

use crate::handlers::HandlerInfo;
use crate::handlers::SaplingRemoteApiMethod;
#[cfg(fbcode_build)]
use crate::middleware::facebook::log_ods3;
#[cfg(not(fbcode_build))]
use crate::middleware::oss::log_ods3;

define_stats! {
prefix = "mononoke.edenapi.request";
Expand Down Expand Up @@ -85,6 +89,7 @@ fn log_stats(state: &mut State, status: StatusCode) -> Option<()> {

let hander_info = state.try_borrow::<HandlerInfo>()?;
let method = hander_info.method?;
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 @@ -164,14 +169,14 @@ 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, request_load);
});

if let Some(request_load) = RequestLoad::try_borrow_from(state) {
STATS::request_load.add_value(request_load.0);
}

Some(())
}

Expand Down
17 changes: 17 additions & 0 deletions eden/mononoke/edenapi_service/src/middleware/oss/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* 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,
_request_load: Option<f64>,
) {
}

0 comments on commit 8dcb0a1

Please sign in to comment.