Skip to content

Commit e4ac031

Browse files
author
brunnert
committed
Fix NullpointerException
1 parent 6310e6d commit e4ac031

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

extension/src/main/java/io/retit/opentelemetry/javaagent/extension/metrics/MetricPublishingService.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,11 @@ private void publishProcessCPUTime(final ObservableLongMeasurement measurement)
137137
}
138138

139139
private void publishDoubleMeasurement(final ObservableDoubleMeasurement measurement, final String type, final double value) {
140-
LOGGER.info("Publishing " + type + " with value " + value);
141-
measurement.record(value, Attributes.of(AttributeKey.stringKey(Constants.RETIT_EMISSIONS_CLOUD_PROVIDER_CONFIGURATION_PROPERTY), CloudCarbonFootprintData.getConfigInstance().getCloudInstanceDetails().getCloudProvider().name(),
142-
AttributeKey.stringKey(Constants.RETIT_EMISSIONS_CLOUD_PROVIDER_INSTANCE_TYPE_CONFIGURATION_PROPERTY), CloudCarbonFootprintData.getConfigInstance().getCloudInstanceDetails().getInstanceType()));
140+
if (CloudCarbonFootprintData.getConfigInstance().getCloudInstanceDetails().getCloudProvider() != null) {
141+
LOGGER.info("Publishing " + type + " with value " + value);
142+
measurement.record(value, Attributes.of(AttributeKey.stringKey(Constants.RETIT_EMISSIONS_CLOUD_PROVIDER_CONFIGURATION_PROPERTY), CloudCarbonFootprintData.getConfigInstance().getCloudInstanceDetails().getCloudProvider().name(),
143+
AttributeKey.stringKey(Constants.RETIT_EMISSIONS_CLOUD_PROVIDER_INSTANCE_TYPE_CONFIGURATION_PROPERTY), CloudCarbonFootprintData.getConfigInstance().getCloudInstanceDetails().getInstanceType()));
144+
}
143145
}
144146

145147
/**

0 commit comments

Comments
 (0)