Skip to content

Commit

Permalink
Log mononoke_api stats to ODS3
Browse files Browse the repository at this point in the history
Summary: SSIA

Reviewed By: clara-9

Differential Revision: D68896627

fbshipit-source-id: 8e83ad9122edf8220462fd3c49fb6b4386ea43a5
  • Loading branch information
andreacampi authored and facebook-github-bot committed Jan 31, 2025
1 parent b25c625 commit 5d9c998
Showing 1 changed file with 48 additions and 8 deletions.
56 changes: 48 additions & 8 deletions eden/mononoke/mononoke_api/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ use git_types::MappedGitCommitId;
use hook_manager::manager::HookManager;
use hook_manager::manager::HookManagerArc;
use itertools::Itertools;
#[cfg(fbcode_build)]
use lazy_static::lazy_static;
use live_commit_sync_config::LiveCommitSyncConfig;
use mercurial_derivation::MappedHgChangesetId;
use mercurial_mutation::HgMutationStore;
Expand Down Expand Up @@ -146,6 +148,12 @@ use unbundle::PushRedirectorArgs;
use wireproto_handler::PushRedirectorBase;
use wireproto_handler::RepoHandlerBase;
use wireproto_handler::RepoHandlerBaseRef;
#[cfg(fbcode_build)]
use MononokeApiStats_ods3::Instrument_MononokeApiStats;
#[cfg(fbcode_build)]
use MononokeApiStats_ods3_types::MononokeApiEvent;
#[cfg(fbcode_build)]
use MononokeApiStats_ods3_types::MononokeApiStats;

use crate::changeset::ChangesetContext;
use crate::errors::MononokeError;
Expand All @@ -171,6 +179,12 @@ pub mod update_submodule_expansion;

pub use git::upload_non_blob_git_object;

#[cfg(fbcode_build)]
lazy_static! {
static ref API_STATS_INSTRUMENT: Instrument_MononokeApiStats =
Instrument_MononokeApiStats::new();
}

define_stats! {
prefix = "mononoke.api";
staleness: dynamic_singleton_counter(
Expand Down Expand Up @@ -503,6 +517,16 @@ fn report_bookmark_missing_from_cache(
1,
(repo.repo_identity().id(), bookmark.to_string()),
);

#[cfg(fbcode_build)]
API_STATS_INSTRUMENT.observe(MononokeApiStats {
repo: Some(repo.repo_identity().name().to_string()),
repoid: Some(repo.repo_identity().id().id()),
bookmark: Some(bookmark.to_string()),
event: Some(MononokeApiEvent::BookmarkNotInCache),
count: Some(1.0),
..Default::default()
});
}

fn report_bookmark_missing_from_repo(
Expand All @@ -520,6 +544,16 @@ fn report_bookmark_missing_from_repo(
1,
(repo.repo_identity().id(), bookmark.to_string()),
);

#[cfg(fbcode_build)]
API_STATS_INSTRUMENT.observe(MononokeApiStats {
repo: Some(repo.repo_identity().name().to_string()),
repoid: Some(repo.repo_identity().id().id()),
bookmark: Some(bookmark.to_string()),
event: Some(MononokeApiEvent::BookmarkNotInRepo),
count: Some(1.0),
..Default::default()
});
}

fn report_bookmark_staleness(
Expand All @@ -544,6 +578,16 @@ fn report_bookmark_staleness(
staleness,
(repo.repo_identity().id(), bookmark.to_string()),
);

#[cfg(fbcode_build)]
API_STATS_INSTRUMENT.observe(MononokeApiStats {
repo: Some(repo.repo_identity().name().to_string()),
repoid: Some(repo.repo_identity().id().id()),
bookmark: Some(bookmark.to_string()),
event: Some(MononokeApiEvent::BookmarkStale),
count: Some(1.0),
..Default::default()
});
}

async fn report_bookmark_age_difference(
Expand Down Expand Up @@ -1617,11 +1661,8 @@ impl<R: MononokeRepo> RepoContext<R> {
MononokeError::InvalidRequest(format!("unknown commit specifier {}", specifier))
})?;

let commit_syncer = CommitSyncer::new(
&self.ctx,
commit_sync_repos.into(),
self.live_commit_sync_config(),
);
let commit_syncer =
CommitSyncer::new(&self.ctx, commit_sync_repos, self.live_commit_sync_config());

if sync_behaviour == XRepoLookupSyncBehaviour::SyncIfAbsent {
let _ = commit_syncer
Expand Down Expand Up @@ -1674,10 +1715,9 @@ impl<R: MononokeRepo> RepoContext<R> {

/// Reads a value out of the underlying config, indicating if we support writes without parents in this repo.
pub fn allow_no_parent_writes(&self) -> bool {
return self
.config()
self.config()
.source_control_service
.permit_commits_without_parents;
.permit_commits_without_parents
}

/// A SegmentedChangelog client repository has a compressed shape of the commit graph but
Expand Down

0 comments on commit 5d9c998

Please sign in to comment.