-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Return typed errors from realtime updates, prepare for realtime statistics #4424
Return typed errors from realtime updates, prepare for realtime statistics #4424
Conversation
a6d26cc
to
b31a2e7
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #4424 +/- ##
===========================================
Coverage 58.22% 58.23%
- Complexity 11204 11215 +11
===========================================
Files 1480 1482 +2
Lines 59131 59249 +118
Branches 6783 6784 +1
===========================================
+ Hits 34431 34502 +71
- Misses 22644 22686 +42
- Partials 2056 2061 +5 ☔ View full report in Codecov by Sentry. |
0294a0e
to
16e962e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I misunderstood you in the developer meeting. I thought you meant you had changed the default log level of these classes from the logback config but instead you have changed the log level of some calls. I think this is ok. Only minor problem is that there is quite a lot of spam on the debug log level (at least when using an MQTT updater). Should we have these realtime classes grouped in the logback.xml file so that the log level could be easily changed by a developer?
src/ext/java/org/opentripplanner/ext/siri/SiriTimetableSnapshotSource.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/updater/stoptime/TimetableSnapshotSource.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/updater/stoptime/TimetableSnapshotSource.java
Outdated
Show resolved
Hide resolved
warn(tripId, "TripUpdate contains no updates, skipping."); | ||
return false; | ||
debug(tripId, "TripUpdate contains no updates, skipping."); | ||
UpdateError.of(tripId, NO_UPDATES); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this check is duplicate of the check from createUpdatedTripTimes
which returned the TOO_FEW_STOPS
error. Should we remove one of these checks?
src/main/java/org/opentripplanner/updater/stoptime/TimetableSnapshotSource.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/updater/stoptime/TimetableSnapshotSource.java
Outdated
Show resolved
Hide resolved
src/ext/java/org/opentripplanner/ext/siri/SiriTimetableSnapshotSource.java
Outdated
Show resolved
Hide resolved
src/ext/java/org/opentripplanner/ext/siri/SiriTimetableSnapshotSource.java
Outdated
Show resolved
Hide resolved
src/ext/java/org/opentripplanner/ext/siri/SiriTimetableSnapshotSource.java
Outdated
Show resolved
Hide resolved
3cd8494
to
2c3247d
Compare
…apshotSource.java Co-authored-by: Hannes Junnila <[email protected]>
5dbeded
to
8e24059
Compare
@@ -302,7 +308,7 @@ public void applyEstimatedTimetable( | |||
} | |||
} else { | |||
// Updated trip | |||
if (handleModifiedTrip(transitModel, fuzzyTripMatcher, feedId, journey)) { | |||
if (handleModifiedTrip(transitModel, fuzzyTripMatcher, feedId, journey).isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still has this check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method returns a List<UpdateError>
. Would you prefer it to return a Result<Void, List<UpdateError>>
?
After having thought about it for a bit I think that using a Result
is correct, even though it's a slightly overcomplicated type. WDYT?
<logger name="org.opentripplanner.model.Timetable" level="warn" /> | ||
<logger name="org.opentripplanner.ext.siri.SiriTimetableSnapshotSource" level="warn" /> | ||
<logger name="org.opentripplanner.ext.siri.TimetableHelper" level="warn" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional that these have warn as default? I don't know if it's better for these classes than info but just wanted to ask if you had left them like that by accident.
@@ -1104,12 +1115,12 @@ private boolean addTripToGraphAndBuffer( | |||
); | |||
|
|||
// Add new trip times to the buffer and return success | |||
final boolean updated = buffer.update(pattern, updatedTripTimes, serviceDate); | |||
var maybeError = buffer.update(pattern, updatedTripTimes, serviceDate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we convert this into a Result?
Summary
Right now the realtime updates return either a
false
ornull
to indicate an error. Instead of proper statistics OTP instead logs lots of errors which are hard to analyse.In this PR I return proper error types:
Optional<UpdateError>
Result<TripTimesPatch, UpdateError>
Result
is a newly introduced type that contains two result states of a computation: a success or a failure. This is very similar to an Either in functional languages.Future
This PR enables future development where you can aggregate metrics and return them in Prometheus or an HTTP endpoint.
Basically what is described in #4206.
Log improvements
Before
Lots and lots of these:
After
Unit tests
Added.
Documentation
n/a