Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging of siri errors to SiriAzureETUpdater #5475

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -1,5 +1,7 @@
package org.opentripplanner.ext.siri.updater.azure;

import static net.logstash.logback.argument.StructuredArguments.keyValue;

import com.azure.messaging.servicebus.ServiceBusErrorContext;
import com.azure.messaging.servicebus.ServiceBusReceivedMessageContext;
import jakarta.xml.bind.JAXBException;
Expand All @@ -14,11 +16,13 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import javax.xml.stream.XMLStreamException;
import org.apache.hc.core5.net.URIBuilder;
import org.opentripplanner.ext.siri.SiriTimetableSnapshotSource;
import org.opentripplanner.framework.time.DurationUtils;
import org.opentripplanner.transit.service.TransitModel;
import org.opentripplanner.updater.spi.UpdateError;
import org.opentripplanner.updater.spi.UpdateResult;
import org.opentripplanner.updater.trip.metrics.TripUpdateMetrics;
import org.rutebanken.siri20.util.SiriXml;
Expand Down Expand Up @@ -106,13 +110,15 @@ private void processMessage(String message, String id) {
}

super.saveResultOnGraph.execute((graph, transitModel) -> {
snapshotSource.applyEstimatedTimetable(
var result = snapshotSource.applyEstimatedTimetable(
fuzzyTripMatcher(),
entityResolver(),
feedId,
false,
updates
);
logErrors(result);
recordMetrics.accept(result);
});
} catch (JAXBException | XMLStreamException e) {
LOG.error(e.getLocalizedMessage(), e);
Expand All @@ -138,6 +144,7 @@ private void processHistory(String message, String id) {
false,
updates
);
logErrors(result);
recordMetrics.accept(result);

setPrimed(true);
Expand Down Expand Up @@ -174,4 +181,25 @@ private List<EstimatedTimetableDeliveryStructure> getUpdates(String message, Str

return siri.getServiceDelivery().getEstimatedTimetableDeliveries();
}

private void logErrors(UpdateResult updateResult) {
if (updateResult.failed() == 0) {
return;
}
var errorIndex = updateResult.failures();
leonardehrenfried marked this conversation as resolved.
Show resolved Hide resolved
errorIndex
.keySet()
.forEach(key -> {
var value = errorIndex.get(key);
var tripIds = value.stream().map(UpdateError::debugId).collect(Collectors.toSet());
LOG.warn(
"[{} {}] {} failures of {}: {}",
keyValue("feedId", feedId),
keyValue("type", "siri-et"),
value.size(),
keyValue("errorType", key),
tripIds
);
});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.opentripplanner.ext.siri.updater.azure;

import com.azure.core.amqp.implementation.ConnectionStringProperties;
import java.time.LocalDate;
import org.opentripplanner.updater.trip.UrlUpdaterParameters;

Expand All @@ -23,6 +24,11 @@ public void setFromDateTime(LocalDate fromDateTime) {

@Override
public String url() {
return getDataInitializationUrl();
var url = getServiceBusUrl();
try {
return new ConnectionStringProperties(url).getEndpoint().toString();
} catch (IllegalArgumentException e) {
return url;
}
}
}
Loading