Skip to content

Commit fea751b

Browse files
Merge pull request #123 from iExecBlockchainComputing/bugfix/set-one-for-gauge-version
Fix NaN value for gauge version
2 parents 4a2ab20 + 7369adc commit fea751b

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ All notable changes to this project will be documented in this file.
99
- Send up to 2 blockchain transactions per block.
1010
With a big enough latency, the nonce is properly computed in web3j library against the pending block. (#111)
1111
- Add `BlockchainAdapterService` class to implement interactions with REST API. (#117 #118 #119)
12-
- Expose version through prometheus endpoint and through VersionController. (#122)
12+
- Expose version through prometheus endpoint and through VersionController. (#122 #123)
1313

1414
### Bug Fixes
1515

src/main/java/com/iexec/blockchain/version/VersionController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public class VersionController {
3232
public static final String METRIC_INFO_GAUGE_DESC = "A metric to expose version and application name.";
3333
public static final String METRIC_INFO_LABEL_APP_NAME = "iexecAppName";
3434
public static final String METRIC_INFO_LABEL_APP_VERSION = "iexecAppVersion";
35-
35+
// Must be static final to avoid garbage collect and side effect on gauge
36+
public static final int METRIC_VALUE = 1;
3637
private final BuildProperties buildProperties;
3738

3839
public VersionController(BuildProperties buildProperties) {
@@ -41,7 +42,7 @@ public VersionController(BuildProperties buildProperties) {
4142

4243
@PostConstruct
4344
void initializeGaugeVersion() {
44-
Gauge.builder(METRIC_INFO_GAUGE_NAME, 1.0, n -> n)
45+
Gauge.builder(METRIC_INFO_GAUGE_NAME, METRIC_VALUE, n -> METRIC_VALUE)
4546
.description(METRIC_INFO_GAUGE_DESC)
4647
.tags(METRIC_INFO_LABEL_APP_VERSION, buildProperties.getVersion(),
4748
METRIC_INFO_LABEL_APP_NAME, buildProperties.getName())

src/test/java/com/iexec/blockchain/version/VersionControllerTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,6 @@ void shouldReturnInfoGauge() {
7575
id -> id.getTag(VersionController.METRIC_INFO_LABEL_APP_VERSION)
7676
)
7777
.containsExactly(buildProperties.getName(), buildProperties.getVersion());
78+
assertThat(info.value()).isEqualTo(VersionController.METRIC_VALUE);
7879
}
7980
}

0 commit comments

Comments
 (0)