Record metrics for WHOIS commands

Note that this does not write out metrics for invocations of the
nomulus tool.

This requires a slight refactoring of the existing WhoisResponse
interface so as to also support returning the number of results found
by the WHOIS query.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=149461208
This commit is contained in:
mcilwain 2017-03-07 13:48:07 -08:00 committed by Ben McIlwain
parent 4eef02f17f
commit 3fcb564251
15 changed files with 247 additions and 62 deletions

View file

@ -14,13 +14,14 @@
package google.registry.whois;
import com.google.auto.value.AutoValue;
import org.joda.time.DateTime;
/** Representation of a WHOIS query response. */
public interface WhoisResponse {
/**
* Returns a plain text WHOIS response.
* Returns the WHOIS response.
*
* @param preferUnicode if {@code false} will cause the output to be converted to ASCII whenever
* possible; for example, converting IDN hostname labels to punycode. However certain things
@ -29,10 +30,19 @@ public interface WhoisResponse {
* be set to {@code true}.
* @param disclaimer text to show at bottom of output
*/
String getPlainTextOutput(boolean preferUnicode, String disclaimer);
WhoisResponseResults getResponse(boolean preferUnicode, String disclaimer);
/**
* Returns the time at which this response was created.
*/
/** Returns the time at which this response was created. */
DateTime getTimestamp();
/** A wraper class for the plaintext response of a WHOIS command and its number of results. */
@AutoValue
abstract static class WhoisResponseResults {
public abstract String plainTextOutput();
public abstract int numResults();
static WhoisResponseResults create(String plainTextOutput, int numResults) {
return new AutoValue_WhoisResponse_WhoisResponseResults(plainTextOutput, numResults);
}
}
}