mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
Add a metric for EPP processing time regardless of ID/TLD (#163)
* Add a metric for EPP processing time regardless of ID/TLD * Change name to request_time * Record EPP processing time by traffic type * grammar * request type * semicolon
This commit is contained in:
parent
6bdaf9b8ac
commit
b3cee90a17
1 changed files with 36 additions and 10 deletions
|
@ -39,6 +39,13 @@ public class EppMetrics {
|
||||||
LabelDescriptor.create("tld", "The TLD acted on by the command (if applicable)."),
|
LabelDescriptor.create("tld", "The TLD acted on by the command (if applicable)."),
|
||||||
LabelDescriptor.create("status", "The return status of the command."));
|
LabelDescriptor.create("status", "The return status of the command."));
|
||||||
|
|
||||||
|
private static final ImmutableSet<LabelDescriptor> LABEL_DESCRIPTORS =
|
||||||
|
ImmutableSet.of(
|
||||||
|
LabelDescriptor.create("command", "The name of the command."),
|
||||||
|
LabelDescriptor.create("traffic_type",
|
||||||
|
"The traffic type of the command; one of CANARY, PROBER, or REAL."),
|
||||||
|
LabelDescriptor.create("status", "The return status of the command."));
|
||||||
|
|
||||||
private static final IncrementableMetric eppRequestsByRegistrar =
|
private static final IncrementableMetric eppRequestsByRegistrar =
|
||||||
MetricRegistryImpl.getDefault()
|
MetricRegistryImpl.getDefault()
|
||||||
.newIncrementableMetric(
|
.newIncrementableMetric(
|
||||||
|
@ -73,6 +80,19 @@ public class EppMetrics {
|
||||||
LABEL_DESCRIPTORS_BY_TLD,
|
LABEL_DESCRIPTORS_BY_TLD,
|
||||||
DEFAULT_FITTER);
|
DEFAULT_FITTER);
|
||||||
|
|
||||||
|
private static final EventMetric requestTime =
|
||||||
|
MetricRegistryImpl.getDefault()
|
||||||
|
.newEventMetric(
|
||||||
|
"/epp/request_time",
|
||||||
|
"EPP Request Time",
|
||||||
|
"milliseconds",
|
||||||
|
LABEL_DESCRIPTORS,
|
||||||
|
DEFAULT_FITTER);
|
||||||
|
|
||||||
|
private enum TrafficType {
|
||||||
|
CANARY, PROBER, REAL
|
||||||
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public EppMetrics() {}
|
public EppMetrics() {}
|
||||||
|
|
||||||
|
@ -97,15 +117,21 @@ public class EppMetrics {
|
||||||
metric.getStatus().isPresent() ? String.valueOf(metric.getStatus().get().code) : "";
|
metric.getStatus().isPresent() ? String.valueOf(metric.getStatus().get().code) : "";
|
||||||
long processingTime =
|
long processingTime =
|
||||||
metric.getEndTimestamp().getMillis() - metric.getStartTimestamp().getMillis();
|
metric.getEndTimestamp().getMillis() - metric.getStartTimestamp().getMillis();
|
||||||
processingTimeByRegistrar.record(
|
String commandName = metric.getCommandName().orElse("");
|
||||||
processingTime,
|
processingTimeByRegistrar
|
||||||
metric.getCommandName().orElse(""),
|
.record(processingTime, commandName, metric.getClientId().orElse(""), eppStatusCode);
|
||||||
metric.getClientId().orElse(""),
|
String tld = metric.getTld().orElse("");
|
||||||
eppStatusCode);
|
processingTimeByTld.record(processingTime, commandName, tld, eppStatusCode);
|
||||||
processingTimeByTld.record(
|
requestTime.record(processingTime, commandName, getTrafficType(tld).toString(), eppStatusCode);
|
||||||
processingTime,
|
}
|
||||||
metric.getCommandName().orElse(""),
|
|
||||||
metric.getTld().orElse(""),
|
private static TrafficType getTrafficType(String tld) {
|
||||||
eppStatusCode);
|
if (tld.endsWith("canary.test")) {
|
||||||
|
return TrafficType.CANARY;
|
||||||
|
} else if (tld.endsWith(".test")) {
|
||||||
|
return TrafficType.PROBER;
|
||||||
|
} else {
|
||||||
|
return TrafficType.REAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue