Add metrics for registrar console requests

Cardinality of this metric:

clientId: there are currently 650 (on sandbox, because of OTE), and 200 on production.
explicitClientId: 2
roles: 2 now, might be 3 soon if we add vendors
status: 2

So we're talking about a cardinality of 2,000-8,000. Less when you consider that registrars only seldom actually need to access the console (certainly not daily or even weekly).

Compare with, e.g., the /epp/processing_time from the above EppMetrics.java which has:
Epp commands: 26 (manual counting)
client IDs: 200 on prod
status: the actual status CODE of the command. Can have many values, but looking at the past few weeks' metrics I counted 20
Note that not every command results in every status. Looking a few weeks back we can see around 80-100 (commands+status) combination.
buckets: 16

so that's over 250,000-1,000,000 cardinality, on a very high-volume metric.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=218699280
This commit is contained in:
guyben 2018-10-25 09:34:21 -07:00 committed by jianglai
parent f6d9b46622
commit 97aa98eb35
11 changed files with 223 additions and 25 deletions

View file

@ -75,6 +75,7 @@ public final class ConsoleUiAction implements Runnable {
@Inject HttpServletRequest req;
@Inject Response response;
@Inject RegistrarConsoleMetrics registrarConsoleMetrics;
@Inject AuthenticatedRegistrarAccessor registrarAccessor;
@Inject UserService userService;
@Inject XsrfTokenManager xsrfTokenManager;
@ -134,15 +135,19 @@ public final class ConsoleUiAction implements Runnable {
data.put("username", user.getNickname());
data.put("logoutUrl", userService.createLogoutURL(PATH));
data.put("xsrfToken", xsrfTokenManager.generateToken(user.getEmail()));
ImmutableSetMultimap<String, Role> roleMap = registrarAccessor.getAllClientIdWithRoles();
ImmutableSetMultimap<Role, String> roleMapInverse = roleMap.inverse();
// TODO(guyben):just return all the clientIDs in a single list, and add an "isAdmin" or "roles"
// item
data.put("ownerClientIds", roleMapInverse.get(OWNER));
data.put(
"adminClientIds", Sets.difference(roleMapInverse.get(ADMIN), roleMapInverse.get(OWNER)));
// We set the initual value to the value that will show if guessClientId throws.
String clientId = "<null>";
try {
String clientId = paramClientId.orElse(registrarAccessor.guessClientId());
clientId = paramClientId.orElse(registrarAccessor.guessClientId());
data.put("clientId", clientId);
ImmutableSetMultimap<Role, String> roleMap =
registrarAccessor.getAllClientIdWithRoles().inverse();
data.put("ownerClientIds", roleMap.get(OWNER));
data.put("adminClientIds", Sets.difference(roleMap.get(ADMIN), roleMap.get(OWNER)));
// We want to load the registrar even if we won't use it later (even if we remove the
// requireFeeExtension) - to make sure the user indeed has access to the guessed registrar.
//
@ -162,7 +167,13 @@ public final class ConsoleUiAction implements Runnable {
.setCssRenamingMap(CSS_RENAMING_MAP_SUPPLIER.get())
.setData(data)
.render());
registrarConsoleMetrics.registerConsoleRequest(
clientId, paramClientId.isPresent(), roleMap.get(clientId), "FORBIDDEN");
return;
} catch (Exception e) {
registrarConsoleMetrics.registerConsoleRequest(
clientId, paramClientId.isPresent(), roleMap.get(clientId), "UNEXPECTED ERROR");
throw e;
}
String payload = TOFU_SUPPLIER.get()
@ -171,5 +182,7 @@ public final class ConsoleUiAction implements Runnable {
.setData(data)
.render();
response.setPayload(payload);
registrarConsoleMetrics.registerConsoleRequest(
clientId, paramClientId.isPresent(), roleMap.get(clientId), "SUCCESS");
}
}