Expose Stackdriver's useSemanticMetricTypes property
See gh-28403
This commit is contained in:
parent
4903ce1806
commit
9397121a98
|
@ -47,6 +47,14 @@ public class StackdriverProperties extends StepRegistryProperties {
|
|||
*/
|
||||
private Map<String, String> resourceLabels;
|
||||
|
||||
/**
|
||||
* Whether to use semantically correct metric types. When this is false, counter
|
||||
* metrics are published as the GAUGE MetricKind. When this is true, counter metrics
|
||||
* are published as the CUMULATIVE MetricKind. This is false by default for the sake
|
||||
* of backwards compatibility.
|
||||
*/
|
||||
private boolean useSemanticMetricTypes = false;
|
||||
|
||||
public String getProjectId() {
|
||||
return this.projectId;
|
||||
}
|
||||
|
@ -71,4 +79,12 @@ public class StackdriverProperties extends StepRegistryProperties {
|
|||
this.resourceLabels = resourceLabels;
|
||||
}
|
||||
|
||||
boolean isUseSemanticMetricTypes() {
|
||||
return this.useSemanticMetricTypes;
|
||||
}
|
||||
|
||||
void setUseSemanticMetricTypes(boolean useSemanticMetricTypes) {
|
||||
this.useSemanticMetricTypes = useSemanticMetricTypes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,4 +55,9 @@ public class StackdriverPropertiesConfigAdapter extends StepRegistryPropertiesCo
|
|||
return get(StackdriverProperties::getResourceLabels, StackdriverConfig.super::resourceLabels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useSemanticMetricTypes() {
|
||||
return get(StackdriverProperties::isUseSemanticMetricTypes, StackdriverConfig.super::useSemanticMetricTypes);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,4 +55,13 @@ class StackdriverPropertiesConfigAdapterTests {
|
|||
.containsExactlyInAnyOrderEntriesOf(labels);
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenPropertiesUseSemanticMetricTypesIsSetAdapterResourceTypeReturnsIt() {
|
||||
StackdriverProperties properties = new StackdriverProperties();
|
||||
properties.setUseSemanticMetricTypes(true);
|
||||
assertThat(new StackdriverPropertiesConfigAdapter(properties).useSemanticMetricTypes()).isTrue();
|
||||
properties.setUseSemanticMetricTypes(false);
|
||||
assertThat(new StackdriverPropertiesConfigAdapter(properties).useSemanticMetricTypes()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,6 +36,7 @@ class StackdriverPropertiesTests extends StepRegistryPropertiesTests {
|
|||
StackdriverConfig config = (key) -> null;
|
||||
assertStepRegistryDefaultValues(properties, config);
|
||||
assertThat(properties.getResourceType()).isEqualTo(config.resourceType());
|
||||
assertThat(properties.isUseSemanticMetricTypes()).isEqualTo(config.useSemanticMetricTypes());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue