Merge branch '3.0.x' into 3.1.x

Closes gh-36559
pull/36766/head
Andy Wilkinson 1 year ago
commit 2766c4b648

@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@ -54,6 +54,12 @@ public class StackdriverProperties extends StepRegistryProperties {
*/
private boolean useSemanticMetricTypes = false;
/**
* Prefix for metric type. Valid prefixes are described in the Google Cloud
* documentation (https://cloud.google.com/monitoring/custom-metrics#identifier).
*/
private String metricTypePrefix = "custom.googleapis.com/";
public String getProjectId() {
return this.projectId;
}
@ -86,4 +92,12 @@ public class StackdriverProperties extends StepRegistryProperties {
this.useSemanticMetricTypes = useSemanticMetricTypes;
}
public String getMetricTypePrefix() {
return this.metricTypePrefix;
}
public void setMetricTypePrefix(String metricTypePrefix) {
this.metricTypePrefix = metricTypePrefix;
}
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@ -60,4 +60,9 @@ public class StackdriverPropertiesConfigAdapter extends StepRegistryPropertiesCo
return get(StackdriverProperties::isUseSemanticMetricTypes, StackdriverConfig.super::useSemanticMetricTypes);
}
@Override
public String metricTypePrefix() {
return get(StackdriverProperties::getMetricTypePrefix, StackdriverConfig.super::metricTypePrefix);
}
}

@ -62,4 +62,12 @@ class StackdriverPropertiesConfigAdapterTests {
assertThat(new StackdriverPropertiesConfigAdapter(properties).useSemanticMetricTypes()).isTrue();
}
@Test
void whenPropertiesMetricTypePrefixIsSetAdapterMetricTypePrefixReturnsIt() {
StackdriverProperties properties = new StackdriverProperties();
properties.setMetricTypePrefix("external.googleapis.com/prometheus");
assertThat(new StackdriverPropertiesConfigAdapter(properties).metricTypePrefix())
.isEqualTo("external.googleapis.com/prometheus");
}
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 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.
@ -37,6 +37,7 @@ class StackdriverPropertiesTests extends StepRegistryPropertiesTests {
assertStepRegistryDefaultValues(properties, config);
assertThat(properties.getResourceType()).isEqualTo(config.resourceType());
assertThat(properties.isUseSemanticMetricTypes()).isEqualTo(config.useSemanticMetricTypes());
assertThat(properties.getMetricTypePrefix()).isEqualTo(config.metricTypePrefix());
}
}

Loading…
Cancel
Save