Skip to content

Commit

Permalink
Merge pull request #28403 from jonatan-ivanov
Browse files Browse the repository at this point in the history
* gh-28403:
  Polish "Expose Stackdriver's useSemanticMetricTypes property"
  Expose Stackdriver's useSemanticMetricTypes property

Closes gh-28403
  • Loading branch information
wilkinsona committed Oct 21, 2021
2 parents 4903ce1 + 284725f commit b4e4bfc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
Expand Up @@ -47,6 +47,13 @@ public class StackdriverProperties extends StepRegistryProperties {
*/
private Map<String, String> resourceLabels;

/**
* Whether to use semantically correct metric types. When false, counter metrics are
* published as the GAUGE MetricKind. When true, counter metrics are published as the
* CUMULATIVE MetricKind.
*/
private boolean useSemanticMetricTypes = false;

public String getProjectId() {
return this.projectId;
}
Expand All @@ -71,4 +78,12 @@ public void setResourceLabels(Map<String, String> resourceLabels) {
this.resourceLabels = resourceLabels;
}

boolean isUseSemanticMetricTypes() {
return this.useSemanticMetricTypes;
}

void setUseSemanticMetricTypes(boolean useSemanticMetricTypes) {
this.useSemanticMetricTypes = useSemanticMetricTypes;
}

}
Expand Up @@ -55,4 +55,9 @@ public Map<String, String> resourceLabels() {
return get(StackdriverProperties::getResourceLabels, StackdriverConfig.super::resourceLabels);
}

@Override
public boolean useSemanticMetricTypes() {
return get(StackdriverProperties::isUseSemanticMetricTypes, StackdriverConfig.super::useSemanticMetricTypes);
}

}
Expand Up @@ -55,4 +55,11 @@ void whenPropertiesResourceLabelsAreSetAdapterResourceLabelsReturnsThem() {
.containsExactlyInAnyOrderEntriesOf(labels);
}

@Test
void whenPropertiesUseSemanticMetricTypesIsSetAdapterResourceTypeReturnsIt() {
StackdriverProperties properties = new StackdriverProperties();
properties.setUseSemanticMetricTypes(true);
assertThat(new StackdriverPropertiesConfigAdapter(properties).useSemanticMetricTypes()).isTrue();
}

}
@@ -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.
Expand Down Expand Up @@ -36,6 +36,7 @@ void defaultValuesAreConsistent() {
StackdriverConfig config = (key) -> null;
assertStepRegistryDefaultValues(properties, config);
assertThat(properties.getResourceType()).isEqualTo(config.resourceType());
assertThat(properties.isUseSemanticMetricTypes()).isEqualTo(config.useSemanticMetricTypes());
}

}

0 comments on commit b4e4bfc

Please sign in to comment.