mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Truncate how much info we log about updated premium lists
It doesn't make sense to log all 10K+ lines of a premium list every time it's updated, and indeed that seems to hurt performance, yet that's precisely what we were doing. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=194449836
This commit is contained in:
parent
4657b8ab51
commit
d95f286e58
3 changed files with 16 additions and 2 deletions
|
@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import google.registry.request.JsonResponse;
|
import google.registry.request.JsonResponse;
|
||||||
import google.registry.request.Parameter;
|
import google.registry.request.Parameter;
|
||||||
import google.registry.util.FormattingLogger;
|
import google.registry.util.FormattingLogger;
|
||||||
|
import java.util.logging.Level;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +28,8 @@ public abstract class CreateOrUpdatePremiumListAction implements Runnable {
|
||||||
|
|
||||||
protected static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
protected static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||||
|
|
||||||
|
private static final int MAX_LOGGING_PREMIUM_LIST_LENGTH = 1000;
|
||||||
|
|
||||||
public static final String NAME_PARAM = "name";
|
public static final String NAME_PARAM = "name";
|
||||||
public static final String INPUT_PARAM = "inputData";
|
public static final String INPUT_PARAM = "inputData";
|
||||||
|
|
||||||
|
@ -47,6 +50,17 @@ public abstract class CreateOrUpdatePremiumListAction implements Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Logs the premium list data at INFO, truncated if too long. */
|
||||||
|
void logInputData() {
|
||||||
|
if (logger.isLoggable(Level.INFO)) {
|
||||||
|
logger.infofmt(
|
||||||
|
"Received the following input data: %s",
|
||||||
|
(inputData.length() < MAX_LOGGING_PREMIUM_LIST_LENGTH)
|
||||||
|
? inputData
|
||||||
|
: (inputData.substring(0, MAX_LOGGING_PREMIUM_LIST_LENGTH) + "<truncated>"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Creates a new premium list or updates an existing one. */
|
/** Creates a new premium list or updates an existing one. */
|
||||||
protected abstract void savePremiumList();
|
protected abstract void savePremiumList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class CreatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.infofmt("Saving premium list for TLD %s", name);
|
logger.infofmt("Saving premium list for TLD %s", name);
|
||||||
logger.infofmt("Got the following input data: %s", inputData);
|
logInputData();
|
||||||
List<String> inputDataPreProcessed =
|
List<String> inputDataPreProcessed =
|
||||||
Splitter.on('\n').omitEmptyStrings().splitToList(inputData);
|
Splitter.on('\n').omitEmptyStrings().splitToList(inputData);
|
||||||
PremiumList premiumList = new PremiumList.Builder().setName(name).build();
|
PremiumList premiumList = new PremiumList.Builder().setName(name).build();
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class UpdatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||||
name);
|
name);
|
||||||
|
|
||||||
logger.infofmt("Updating premium list for TLD %s", name);
|
logger.infofmt("Updating premium list for TLD %s", name);
|
||||||
logger.infofmt("Got the following input data: %s", inputData);
|
logInputData();
|
||||||
List<String> inputDataPreProcessed =
|
List<String> inputDataPreProcessed =
|
||||||
Splitter.on('\n').omitEmptyStrings().splitToList(inputData);
|
Splitter.on('\n').omitEmptyStrings().splitToList(inputData);
|
||||||
PremiumList newPremiumList =
|
PremiumList newPremiumList =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue