
org.opentripplanner.updater.trip.metrics.TripUpdateMetrics Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
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