mirror of
https://github.com/google/nomulus.git
synced 2025-07-21 10:16:07 +02:00
Add metrics for the new Check API
New metrics are necessary because the new API no longer wraps an EPP flow, therefore does not get metrics for free. Metrics include - An EventMetric for processing time - An IncrementableMetric for request count, with availability (available/reserved/registered) and pricing (standard/premium) fields ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=199708592
This commit is contained in:
parent
1c71487e5d
commit
658f31933c
7 changed files with 391 additions and 30 deletions
124
java/google/registry/monitoring/whitebox/CheckApiMetric.java
Normal file
124
java/google/registry/monitoring/whitebox/CheckApiMetric.java
Normal file
|
@ -0,0 +1,124 @@
|
|||
// Copyright 2018 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.monitoring.whitebox;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import google.registry.util.Clock;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** A value class for recording attributes of a domain check metric. */
|
||||
@AutoValue
|
||||
public abstract class CheckApiMetric {
|
||||
|
||||
/** Price tier of a domain name. */
|
||||
public enum Tier {
|
||||
STANDARD("standard"),
|
||||
PREMINUM("premium");
|
||||
|
||||
private final String displayLabel;
|
||||
|
||||
private Tier(String displayLabel) {
|
||||
this.displayLabel = displayLabel;
|
||||
}
|
||||
|
||||
public String getDisplayLabel() {
|
||||
return displayLabel;
|
||||
}
|
||||
}
|
||||
|
||||
/** Availability status of a domain. */
|
||||
public enum Availability {
|
||||
RESERVED("reserved"),
|
||||
REGISTERED("registered"),
|
||||
AVAILABLE("available");
|
||||
|
||||
private final String displayLabel;
|
||||
|
||||
private Availability(String displayLabel) {
|
||||
this.displayLabel = displayLabel;
|
||||
}
|
||||
|
||||
public String getDisplayLabel() {
|
||||
return displayLabel;
|
||||
}
|
||||
}
|
||||
|
||||
/** Status of the CheckApi command. */
|
||||
public enum Status {
|
||||
SUCCESS("success"),
|
||||
INVALID_NAME("invalid_name"),
|
||||
INVALID_REGISTRY_PHASE("invalid_registry_phase"),
|
||||
UNKNOWN_ERROR("unknown_error");
|
||||
|
||||
private final String displayLabel;
|
||||
|
||||
private Status(String displayLabel) {
|
||||
this.displayLabel = displayLabel;
|
||||
}
|
||||
|
||||
public String getDisplayLabel() {
|
||||
return displayLabel;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract DateTime startTimestamp();
|
||||
|
||||
public abstract DateTime endTimestamp();
|
||||
|
||||
public abstract Status status();
|
||||
|
||||
public abstract Optional<Tier> tier();
|
||||
|
||||
public abstract Optional<Availability> availability();
|
||||
|
||||
public static Builder builder(Clock clock) {
|
||||
return new AutoValue_CheckApiMetric.Builder().startTimestamp(clock.nowUtc()).setClock(clock);
|
||||
}
|
||||
|
||||
CheckApiMetric() {}
|
||||
|
||||
/** Builder for {@link CheckApiMetric}. */
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
private Clock clock;
|
||||
|
||||
/** Saves the {@link Clock} for end-time determination. */
|
||||
Builder setClock(Clock clock) {
|
||||
checkNotNull(clock, "clock");
|
||||
this.clock = clock;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CheckApiMetric build() {
|
||||
return this.endTimestamp(clock.nowUtc()).autoBuild();
|
||||
}
|
||||
|
||||
abstract Builder startTimestamp(DateTime startTimestamp);
|
||||
|
||||
abstract Builder endTimestamp(DateTime endTimestamp);
|
||||
|
||||
public abstract Builder status(Status status);
|
||||
|
||||
public abstract Builder tier(Tier tier);
|
||||
|
||||
public abstract Builder availability(Availability availability);
|
||||
|
||||
abstract CheckApiMetric autoBuild();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue