Skip to content

Commit 47fe8b4

Browse files
Clara Rullfacebook-github-bot
authored andcommitted
Log as client_main_id, not main_client_id
Summary: We are logging the same info in 2 different columns: client_main_id and main_client_id. The latter only in the context of rate-limited requests. This should have never been the case, let's fix it Reviewed By: andreacampi Differential Revision: D72091301 fbshipit-source-id: 9fe2aeab34fd1c845b4938cbb274ba1a0e3f7e95
1 parent a75f33e commit 47fe8b4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

eden/mononoke/edenapi_service/src/handlers/commit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,23 +234,23 @@ async fn ratelimit_commit_creation(ctx: CoreContext) -> Result<(), Error> {
234234
let max_value = limit.body.raw_config.limit;
235235
let time_window = limit.fci_metric.window.as_secs() as u32;
236236

237-
let main_client_id = match &client_request_info.main_id {
238-
Some(main_client_id) => main_client_id,
237+
let client_main_id = match &client_request_info.main_id {
238+
Some(client_main_id) => client_main_id,
239239
None => {
240240
debug!(ctx.logger(), "No main client id found");
241241
return Ok(());
242242
}
243243
};
244244

245-
let counter = build_counter(&ctx, category, COMMITS_PER_USER_RATE_LIMIT, main_client_id);
245+
let counter = build_counter(&ctx, category, COMMITS_PER_USER_RATE_LIMIT, client_main_id);
246246
counter_check_and_bump(
247247
&ctx,
248248
counter,
249249
COMMITS_PER_USER_RATE_LIMIT,
250250
max_value,
251251
time_window,
252252
enforced,
253-
hashmap! {"main_client_id" => main_client_id.as_str() },
253+
hashmap! {"client_main_id" => client_main_id.as_str() },
254254
)
255255
.await
256256
}

eden/mononoke/edenapi_service/src/middleware/rate_limiter.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ impl Middleware for ThrottleMiddleware {
5858
debug!(ctx.logger(), "No client request info found");
5959
None
6060
})?;
61-
// Retrieve main client ID
62-
let main_client_id = client_request_info.main_id.clone().or_else(|| {
61+
// Retrieve client main id
62+
let client_main_id = client_request_info.main_id.clone().or_else(|| {
6363
debug!(ctx.logger(), "No main client id found");
6464
None
6565
})?;
@@ -74,7 +74,7 @@ impl Middleware for ThrottleMiddleware {
7474
let limit = rate_limiter.find_rate_limit(
7575
Metric::EdenApiQps,
7676
Some(identities.clone()),
77-
Some(&main_client_id),
77+
Some(&client_main_id),
7878
)?;
7979

8080
let enforced = match limit.body.raw_config.status {
@@ -85,7 +85,7 @@ impl Middleware for ThrottleMiddleware {
8585
};
8686

8787
let category = rate_limiter.category();
88-
let counter = build_counter(&ctx, category, EDENAPI_QPS_LIMIT, &main_client_id);
88+
let counter = build_counter(&ctx, category, EDENAPI_QPS_LIMIT, &client_main_id);
8989
let max_value = limit.body.raw_config.limit;
9090
let time_window = limit.fci_metric.window.as_secs() as u32;
9191

@@ -96,7 +96,7 @@ impl Middleware for ThrottleMiddleware {
9696
max_value,
9797
time_window,
9898
enforced,
99-
hashmap! {"main_client_id" => main_client_id.as_str() },
99+
hashmap! {"client_main_id" => client_main_id.as_str() },
100100
)
101101
.await
102102
{

0 commit comments

Comments
 (0)