Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,20 @@ public D labelValues(String... labelValues) {
"Expected " + labelNames.length + " label values, but got " + labelValues.length + ".");
}
}
return data.computeIfAbsent(
Arrays.asList(labelValues),
l -> {
for (int i = 0; i < l.size(); i++) {
if (l.get(i) == null) {
throw new IllegalArgumentException(
"null label value for metric "
+ metadata.getName()
+ " and label "
+ labelNames[i]);
}
}
return newDataPoint();
});
List<String> key = Arrays.asList(labelValues);
// Fast path: the data point for these label values almost always already exists, since the same
// label combinations are reused across updates.
T dataPoint = data.get(key);
if (dataPoint != null) {
return dataPoint;
}
for (int i = 0; i < labelValues.length; i++) {
if (labelValues[i] == null) {
throw new IllegalArgumentException(
"null label value for metric " + metadata.getName() + " and label " + labelNames[i]);
}
}
return data.computeIfAbsent(key, l -> newDataPoint());
}

/**
Expand Down