mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Factor out labelValue length check to abstract base class and small name fix
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=131902964
This commit is contained in:
parent
a0f1a8b0bc
commit
c11ac3129f
7 changed files with 80 additions and 42 deletions
48
java/google/registry/monitoring/metrics/MetricsUtils.java
Normal file
48
java/google/registry/monitoring/metrics/MetricsUtils.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Copyright 2016 The Domain Registry 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.metrics;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/** Static helper methods for the Metrics library. */
|
||||
final class MetricsUtils {
|
||||
|
||||
private static final String LABEL_SIZE_ERROR =
|
||||
"The count of labelValues must be equal to the underlying Metric's count of labels.";
|
||||
|
||||
private MetricsUtils() {}
|
||||
|
||||
/**
|
||||
* Check that the given {@code labelValues} match in count with the count of {@link
|
||||
* LabelDescriptor} instances on the given {@code metric}
|
||||
*
|
||||
* @throws IllegalArgumentException if there is a count mismatch.
|
||||
*/
|
||||
static void checkLabelValuesLength(Metric<?> metric, String[] labelValues) {
|
||||
checkArgument(labelValues.length == metric.getMetricSchema().labels().size(), LABEL_SIZE_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the given {@code labelValues} match in count with the count of {@link
|
||||
* LabelDescriptor} instances on the given {@code metric}
|
||||
*
|
||||
* @throws IllegalArgumentException if there is a count mismatch.
|
||||
*/
|
||||
static void checkLabelValuesLength(Metric<?> metric, ImmutableList<String> labelValues) {
|
||||
checkArgument(labelValues.size() == metric.getMetricSchema().labels().size(), LABEL_SIZE_ERROR);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue