-
Notifications
You must be signed in to change notification settings - Fork 198
Add application err category #2485
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4fd8dd9
update protos
THardy98 71c11a4
add ApplicationErrorCategory enum
THardy98 1858f95
Add category field to ApplicationFailure
THardy98 4e8a98e
add category proto converter logic
THardy98 433c066
add logging/metrics checks for benign application failures
THardy98 6875557
fixes, added test for workflow failure metric
THardy98 29ff5dc
fixes for activity failures, added test for activity failures
THardy98 44de349
address PR review
THardy98 a64f646
only check immediate failure
THardy98 d22a2ad
define code enum, convert to/from proto representation
THardy98 823848e
cleanup
THardy98 ab0a99a
Merge branch 'master' into add_application_err_category
THardy98 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
33 changes: 33 additions & 0 deletions
33
temporal-sdk/src/main/java/io/temporal/failure/ApplicationErrorCategory.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved. | ||
| * | ||
| * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Modifications copyright (C) 2017 Uber Technologies, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this material except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.temporal.failure; | ||
|
|
||
| /** | ||
| * Used to categorize application failures, for example, to distinguish benign errors from others. | ||
| * | ||
| * @see io.temporal.api.enums.v1.ApplicationErrorCategory | ||
| */ | ||
| public enum ApplicationErrorCategory { | ||
| UNSPECIFIED, | ||
| /** Expected application error with little/no severity. */ | ||
| BENIGN, | ||
| ; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
78 changes: 78 additions & 0 deletions
78
temporal-sdk/src/main/java/io/temporal/internal/common/FailureUtils.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| /* | ||
| * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved. | ||
| * | ||
| * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Modifications copyright (C) 2017 Uber Technologies, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this material except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.temporal.internal.common; | ||
|
|
||
| import io.temporal.api.failure.v1.Failure; | ||
| import io.temporal.failure.ApplicationErrorCategory; | ||
| import io.temporal.failure.ApplicationFailure; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| public class FailureUtils { | ||
|
Contributor
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. Pedantic, but would add a private constructor here |
||
| private FailureUtils() {} | ||
|
|
||
| public static boolean isBenignApplicationFailure(@Nullable Throwable t) { | ||
| if (t instanceof ApplicationFailure | ||
| && ((ApplicationFailure) t).getApplicationErrorCategory() | ||
| == ApplicationErrorCategory.BENIGN) { | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| public static boolean isBenignApplicationFailure(@Nullable Failure failure) { | ||
| if (failure != null | ||
| && failure.getApplicationFailureInfo() != null | ||
| && FailureUtils.categoryFromProto(failure.getApplicationFailureInfo().getCategory()) | ||
| == ApplicationErrorCategory.BENIGN) { | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| public static ApplicationErrorCategory categoryFromProto( | ||
| io.temporal.api.enums.v1.ApplicationErrorCategory protoCategory) { | ||
| if (protoCategory == null) { | ||
| return ApplicationErrorCategory.UNSPECIFIED; | ||
| } | ||
| switch (protoCategory) { | ||
| case APPLICATION_ERROR_CATEGORY_BENIGN: | ||
| return ApplicationErrorCategory.BENIGN; | ||
| case APPLICATION_ERROR_CATEGORY_UNSPECIFIED: | ||
| case UNRECOGNIZED: | ||
| default: | ||
| // Fallback unrecognized or unspecified proto values as UNSPECIFIED | ||
| return ApplicationErrorCategory.UNSPECIFIED; | ||
| } | ||
| } | ||
|
|
||
| public static io.temporal.api.enums.v1.ApplicationErrorCategory categoryToProto( | ||
| io.temporal.failure.ApplicationErrorCategory category) { | ||
| switch (category) { | ||
| case BENIGN: | ||
| return io.temporal.api.enums.v1.ApplicationErrorCategory.APPLICATION_ERROR_CATEGORY_BENIGN; | ||
| case UNSPECIFIED: | ||
| default: | ||
| // Fallback to UNSPECIFIED for unknown values | ||
| return io.temporal.api.enums.v1.ApplicationErrorCategory | ||
| .APPLICATION_ERROR_CATEGORY_UNSPECIFIED; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
It seems in other parts of the SDK, e.g. parent close policy, we just expose the raw enum from proto. Should we do the same here? It has "unrecognized", automatically gets new values, etc.
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.
Didn't notice that, have changed to use raw proto