mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Rename all encoding methods to start with the word encode for consistency
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=143973446
This commit is contained in:
parent
2a3a17d653
commit
e981bad0b3
2 changed files with 18 additions and 18 deletions
|
@ -127,7 +127,7 @@ public class StackdriverWriter implements MetricWriter {
|
|||
private final RateLimiter rateLimiter;
|
||||
|
||||
/**
|
||||
* Constructs a StackdriverWriter.
|
||||
* Constructs a {@link StackdriverWriter}.
|
||||
*
|
||||
* <p>The monitoringClient must have read and write permissions to the Cloud Monitoring API v3 on
|
||||
* the provided project.
|
||||
|
@ -135,7 +135,7 @@ public class StackdriverWriter implements MetricWriter {
|
|||
@Inject
|
||||
public StackdriverWriter(
|
||||
Monitoring monitoringClient,
|
||||
String project,
|
||||
@Named("stackdriverGcpProject") String project,
|
||||
MonitoredResource monitoredResource,
|
||||
@Named("stackdriverMaxQps") int maxQps,
|
||||
@Named("stackdriverMaxPointsPerRequest") int maxPointsPerRequest) {
|
||||
|
@ -148,7 +148,7 @@ public class StackdriverWriter implements MetricWriter {
|
|||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static ImmutableList<LabelDescriptor> createLabelDescriptors(
|
||||
static ImmutableList<LabelDescriptor> encodeLabelDescriptors(
|
||||
ImmutableSet<google.registry.monitoring.metrics.LabelDescriptor> labelDescriptors) {
|
||||
List<LabelDescriptor> stackDriverLabelDescriptors = new ArrayList<>(labelDescriptors.size());
|
||||
|
||||
|
@ -164,14 +164,14 @@ public class StackdriverWriter implements MetricWriter {
|
|||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static <V> MetricDescriptor createMetricDescriptor(
|
||||
static <V> MetricDescriptor encodeMetricDescriptor(
|
||||
google.registry.monitoring.metrics.Metric<V> metric) {
|
||||
return new MetricDescriptor()
|
||||
.setType(METRIC_DOMAIN + metric.getMetricSchema().name())
|
||||
.setDescription(metric.getMetricSchema().description())
|
||||
.setDisplayName(metric.getMetricSchema().valueDisplayName())
|
||||
.setValueType(ENCODED_METRIC_TYPES.get(metric.getValueClass()))
|
||||
.setLabels(createLabelDescriptors(metric.getMetricSchema().labels()))
|
||||
.setLabels(encodeLabelDescriptors(metric.getMetricSchema().labels()))
|
||||
.setMetricKind(ENCODED_METRIC_KINDS.get(metric.getMetricSchema().kind().name()));
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ public class StackdriverWriter implements MetricWriter {
|
|||
return registeredDescriptors.get(metric);
|
||||
}
|
||||
|
||||
MetricDescriptor descriptor = createMetricDescriptor(metric);
|
||||
MetricDescriptor descriptor = encodeMetricDescriptor(metric);
|
||||
|
||||
rateLimiter.acquire();
|
||||
// We try to create a descriptor, but it may have been created already, so we re-fetch it on
|
||||
|
|
|
@ -82,7 +82,7 @@ public class StackdriverWriterTest {
|
|||
"desc",
|
||||
"vdn",
|
||||
ImmutableSet.of(LabelDescriptor.create("label", "description")));
|
||||
descriptor = StackdriverWriter.createMetricDescriptor(metric);
|
||||
descriptor = StackdriverWriter.encodeMetricDescriptor(metric);
|
||||
when(client.projects()).thenReturn(projects);
|
||||
when(projects.metricDescriptors()).thenReturn(metricDescriptors);
|
||||
when(projects.timeSeries()).thenReturn(timeSeries);
|
||||
|
@ -185,7 +185,7 @@ public class StackdriverWriterTest {
|
|||
client
|
||||
.projects()
|
||||
.metricDescriptors()
|
||||
.create(PROJECT, StackdriverWriter.createMetricDescriptor(metric)))
|
||||
.create(PROJECT, StackdriverWriter.encodeMetricDescriptor(metric)))
|
||||
.execute();
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ public class StackdriverWriterTest {
|
|||
client
|
||||
.projects()
|
||||
.metricDescriptors()
|
||||
.create(PROJECT, StackdriverWriter.createMetricDescriptor(metric)))
|
||||
.create(PROJECT, StackdriverWriter.encodeMetricDescriptor(metric)))
|
||||
.execute();
|
||||
}
|
||||
|
||||
|
@ -272,8 +272,8 @@ public class StackdriverWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createMetricDescriptor_simpleMetric_encodes() {
|
||||
MetricDescriptor descriptor = StackdriverWriter.createMetricDescriptor(metric);
|
||||
public void encodeMetricDescriptor_simpleMetric_encodes() {
|
||||
MetricDescriptor descriptor = StackdriverWriter.encodeMetricDescriptor(metric);
|
||||
|
||||
assertThat(descriptor.getType()).isEqualTo("custom.googleapis.com/name");
|
||||
assertThat(descriptor.getValueType()).isEqualTo("INT64");
|
||||
|
@ -288,14 +288,14 @@ public class StackdriverWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createLabelDescriptors_simpleLabels_encodes() {
|
||||
public void encodeLabelDescriptors_simpleLabels_encodes() {
|
||||
ImmutableSet<LabelDescriptor> descriptors =
|
||||
ImmutableSet.of(
|
||||
LabelDescriptor.create("label1", "description1"),
|
||||
LabelDescriptor.create("label2", "description2"));
|
||||
|
||||
ImmutableList<com.google.api.services.monitoring.v3.model.LabelDescriptor> encodedDescritors =
|
||||
StackdriverWriter.createLabelDescriptors(descriptors);
|
||||
StackdriverWriter.encodeLabelDescriptors(descriptors);
|
||||
|
||||
assertThat(encodedDescritors)
|
||||
.containsExactly(
|
||||
|
@ -364,7 +364,7 @@ public class StackdriverWriterTest {
|
|||
ImmutableSet.of(LabelDescriptor.create("label", "description")),
|
||||
Long.class);
|
||||
when(metricDescriptorCreate.execute())
|
||||
.thenReturn(StackdriverWriter.createMetricDescriptor(metric));
|
||||
.thenReturn(StackdriverWriter.encodeMetricDescriptor(metric));
|
||||
MetricPoint<Long> nativePoint =
|
||||
MetricPoint.create(
|
||||
metric, ImmutableList.of("foo"), new Instant(1337), new Instant(1337), 10L);
|
||||
|
@ -392,7 +392,7 @@ public class StackdriverWriterTest {
|
|||
"vdn",
|
||||
ImmutableSet.of(LabelDescriptor.create("label", "description")),
|
||||
Boolean.class);
|
||||
MetricDescriptor boolDescriptor = StackdriverWriter.createMetricDescriptor(boolMetric);
|
||||
MetricDescriptor boolDescriptor = StackdriverWriter.encodeMetricDescriptor(boolMetric);
|
||||
when(metricDescriptorCreate.execute()).thenReturn(boolDescriptor);
|
||||
MetricPoint<Boolean> nativePoint =
|
||||
MetricPoint.create(boolMetric, ImmutableList.of("foo"), new Instant(1337), true);
|
||||
|
@ -420,7 +420,7 @@ public class StackdriverWriterTest {
|
|||
"vdn",
|
||||
ImmutableSet.of(LabelDescriptor.create("label", "description")),
|
||||
Distribution.class);
|
||||
MetricDescriptor descriptor = StackdriverWriter.createMetricDescriptor(metric);
|
||||
MetricDescriptor descriptor = StackdriverWriter.encodeMetricDescriptor(metric);
|
||||
when(metricDescriptorCreate.execute()).thenReturn(descriptor);
|
||||
MutableDistribution distribution =
|
||||
new MutableDistribution(CustomFitter.create(ImmutableSet.of(5.0)));
|
||||
|
@ -461,7 +461,7 @@ public class StackdriverWriterTest {
|
|||
"vdn",
|
||||
ImmutableSet.of(LabelDescriptor.create("label", "description")),
|
||||
Distribution.class);
|
||||
MetricDescriptor descriptor = StackdriverWriter.createMetricDescriptor(metric);
|
||||
MetricDescriptor descriptor = StackdriverWriter.encodeMetricDescriptor(metric);
|
||||
when(metricDescriptorCreate.execute()).thenReturn(descriptor);
|
||||
MutableDistribution distribution = new MutableDistribution(LinearFitter.create(2, 5.0, 3.0));
|
||||
distribution.add(0.0, 1L);
|
||||
|
@ -504,7 +504,7 @@ public class StackdriverWriterTest {
|
|||
"vdn",
|
||||
ImmutableSet.of(LabelDescriptor.create("label", "description")),
|
||||
Distribution.class);
|
||||
MetricDescriptor descriptor = StackdriverWriter.createMetricDescriptor(metric);
|
||||
MetricDescriptor descriptor = StackdriverWriter.encodeMetricDescriptor(metric);
|
||||
when(metricDescriptorCreate.execute()).thenReturn(descriptor);
|
||||
MutableDistribution distribution =
|
||||
new MutableDistribution(ExponentialFitter.create(2, 3.0, 0.5));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue