-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
push failures to segment #10715
Merged
Merged
push failures to segment #10715
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
86d526b
test: new failures metadata for segment tracking
git-phu e4a5be8
new failures metadata for segment tracking
git-phu 8f19fa7
remove attempt_id
git-phu 6ffd6b0
explicitly sort failures array chronologically
git-phu 500035f
replace "unknown" enums with null
git-phu 2e53dfd
move sorting to the correct place
git-phu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,13 @@ | |
|
||
package io.airbyte.scheduler.persistence.job_tracker; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.node.ArrayNode; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.common.collect.ImmutableMap.Builder; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.config.AttemptFailureSummary; | ||
import io.airbyte.config.FailureReason; | ||
import io.airbyte.config.JobOutput; | ||
import io.airbyte.config.ResourceRequirements; | ||
import io.airbyte.config.StandardDestinationDefinition; | ||
|
@@ -15,7 +20,11 @@ | |
import io.airbyte.config.helpers.ScheduleHelpers; | ||
import io.airbyte.scheduler.models.Attempt; | ||
import io.airbyte.scheduler.models.Job; | ||
import java.util.Collection; | ||
import java.util.Comparator; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.concurrent.TimeUnit; | ||
import org.apache.logging.log4j.util.Strings; | ||
|
||
|
@@ -102,9 +111,50 @@ public static ImmutableMap<String, Object> generateJobAttemptMetadata(final Job | |
metadata.put("volume_rows", syncSummary.getRecordsSynced()); | ||
} | ||
} | ||
|
||
final List<FailureReason> failureReasons = failureReasonsList(attempts); | ||
if (!failureReasons.isEmpty()) { | ||
metadata.put("failure_reasons", failureReasonsListAsJson(failureReasons).toString()); | ||
metadata.put("main_failure_reason", failureReasonAsJson(failureReasons.get(0)).toString()); | ||
} | ||
} | ||
} | ||
return metadata.build(); | ||
} | ||
|
||
private static List<FailureReason> failureReasonsList(final List<Attempt> attempts) { | ||
return attempts | ||
.stream() | ||
.map(Attempt::getFailureSummary) | ||
.flatMap(Optional::stream) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This ended up being pretty clean, nice! |
||
.map(AttemptFailureSummary::getFailures) | ||
.flatMap(Collection::stream) | ||
.sorted(Comparator.comparing(FailureReason::getTimestamp)) | ||
.toList(); | ||
} | ||
|
||
private static ArrayNode failureReasonsListAsJson(final List<FailureReason> failureReasons) { | ||
return Jsons.arrayNode().addAll(failureReasons | ||
.stream() | ||
.map(TrackingMetadata::failureReasonAsJson) | ||
.toList()); | ||
} | ||
|
||
private static JsonNode failureReasonAsJson(final FailureReason failureReason) { | ||
// we want the json to always include failureOrigin and failureType, even when they are null | ||
return Jsons.jsonNode(new LinkedHashMap<String, Object>() { | ||
|
||
{ | ||
put("failureOrigin", failureReason.getFailureOrigin()); | ||
put("failureType", failureReason.getFailureType()); | ||
put("internalMessage", failureReason.getInternalMessage()); | ||
put("externalMessage", failureReason.getExternalMessage()); | ||
put("metadata", failureReason.getMetadata()); | ||
put("retryable", failureReason.getRetryable()); | ||
put("timestamp", failureReason.getTimestamp()); | ||
} | ||
|
||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We sort failureReasons chronologically in the
FailureHelper
class, so getting index 0 should be pretty reliable here, but it might make sense to explicitly sort here so that we're not relying on the assumption that these are sorted how the job tracker expects