
org.opentripplanner.updater.trip.metrics.TripUpdateMetrics Maven / Gradle / Ivy
The newest version!
package org.opentripplanner.updater.trip.metrics;
import io.micrometer.core.instrument.Tag;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.opentripplanner.framework.application.OTPFeature;
import org.opentripplanner.updater.spi.UpdateResult;
import org.opentripplanner.updater.trip.UrlUpdaterParameters;
public class TripUpdateMetrics {
public static final Consumer NOOP = ignored -> {};
protected List baseTags;
TripUpdateMetrics(UrlUpdaterParameters parameters) {
this.baseTags = List.of(
Tag.of("configRef", parameters.configRef()),
Tag.of("url", parameters.url()),
Tag.of("feedId", parameters.feedId())
);
}
public static Consumer batch(UrlUpdaterParameters parameters) {
return getConsumer(() -> {
var metrics = new BatchTripUpdateMetrics(parameters);
return metrics::setGauges;
});
}
public static Consumer streaming(UrlUpdaterParameters parameters) {
return getConsumer(() -> {
var metrics = new StreamingTripUpdateMetrics(parameters);
return metrics::setCounters;
});
}
private static Consumer getConsumer(Supplier> maker) {
if (OTPFeature.ActuatorAPI.isOn()) {
return maker.get();
} else {
return NOOP;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy