Skip to content

Commit

Permalink
fix(metrics): fix potential NPE when exporting metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Shichao Nie <niesc@automq.com>
  • Loading branch information
SCNieh committed Sep 19, 2024
1 parent ac9b075 commit d47c2f3
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ private void processDeltaHistogramMetric(MetricName name, DeltaHistogram deltaHi
metrics.compute(otelMetricName, (k, v) -> {
if (v == null) {
v = new ConcurrentHashMap<>();
final Map<MetricName, MetricWrapper> finalV = v;
OTelMetricUtils.toMeanGaugeBuilder(meter, name).buildWithCallback(measurement ->
metrics.get(otelMetricName).forEach((metricname, metricWrapper) ->
finalV.forEach((metricname, metricWrapper) ->
measurement.record(metricWrapper.mean(), metricWrapper.getAttr())));
LOGGER.info("Created delta gauge for metric: {}", otelMetricName);
}
Expand Down

0 comments on commit d47c2f3

Please sign in to comment.