fix NPE when no filter or validator applied

This commit is contained in:
Jonathan Shook 2023-09-10 19:17:45 -05:00
parent 17fa8500ab
commit 7b9f4389b8
2 changed files with 4 additions and 4 deletions

View File

@ -122,8 +122,8 @@ public class Annotators {
} }
public static synchronized void recordAnnotation(Annotation annotation) { public static synchronized void recordAnnotation(Annotation annotation) {
annotation.applyLabelFunction(filter); if (filter!=null) annotation.applyLabelFunction(filter);
annotation.applyLabelFunction(validator); if (validator!=null) annotation.applyLabelFunction(validator);
// sanity check here first // sanity check here first
annotation.getLabels(); annotation.getLabels();
for (Annotator annotator : getAnnotators()) { for (Annotator annotator : getAnnotators()) {

View File

@ -76,8 +76,8 @@ public class ActivityMetrics {
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
private static Metric register(NBLabels labels, MetricProvider metricProvider) { private static Metric register(NBLabels labels, MetricProvider metricProvider) {
labels = labelFilter.apply(labels); labels = labelFilter!=null ? labelFilter.apply(labels) : labels;
labels = labelValidator.apply(labels); labels = labelValidator != null ? labelValidator.apply(labels) : labels;
final String graphiteName = labels.linearizeValues('.',"[activity]","[space]","[op]","name"); final String graphiteName = labels.linearizeValues('.',"[activity]","[space]","[op]","name");
Metric metric = get().getMetrics().get(graphiteName); Metric metric = get().getMetrics().get(graphiteName);