@@ -101,6 +101,34 @@ export const [encodeRetryState, decodeRetryState] = makeProtoEnumConverters<
101101 'RETRY_STATE_'
102102) ;
103103
104+ /**
105+ * A category to describe the severity and change the observability behavior of an application failure.
106+ *
107+ * Currently, observability behaviour changes are limited to:
108+ * - activities that fail due to a BENIGN application failure emit DEBUG level logs and do not record metrics
109+ *
110+ * @experimental Category is a new feature and may be subject to change.
111+ */
112+ export const ApplicationFailureCategory = {
113+ BENIGN : 'BENIGN' ,
114+ } as const ;
115+
116+ export type ApplicationFailureCategory = ( typeof ApplicationFailureCategory ) [ keyof typeof ApplicationFailureCategory ] ;
117+
118+ export const [ encodeApplicationFailureCategory , decodeApplicationFailureCategory ] = makeProtoEnumConverters <
119+ temporal . api . enums . v1 . ApplicationErrorCategory ,
120+ typeof temporal . api . enums . v1 . ApplicationErrorCategory ,
121+ keyof typeof temporal . api . enums . v1 . ApplicationErrorCategory ,
122+ typeof ApplicationFailureCategory ,
123+ 'APPLICATION_ERROR_CATEGORY_'
124+ > (
125+ {
126+ [ ApplicationFailureCategory . BENIGN ] : 1 ,
127+ UNSPECIFIED : 0 ,
128+ } as const ,
129+ 'APPLICATION_ERROR_CATEGORY_'
130+ ) ;
131+
104132export type WorkflowExecution = temporal . api . common . v1 . IWorkflowExecution ;
105133
106134/**
@@ -172,7 +200,8 @@ export class ApplicationFailure extends TemporalFailure {
172200 public readonly nonRetryable ?: boolean | undefined | null ,
173201 public readonly details ?: unknown [ ] | undefined | null ,
174202 cause ?: Error ,
175- public readonly nextRetryDelay ?: Duration | undefined | null
203+ public readonly nextRetryDelay ?: Duration | undefined | null ,
204+ public readonly category ?: ApplicationFailureCategory | undefined | null
176205 ) {
177206 super ( message , cause ) ;
178207 }
@@ -195,8 +224,8 @@ export class ApplicationFailure extends TemporalFailure {
195224 * By default, will be retryable (unless its `type` is included in {@link RetryPolicy.nonRetryableErrorTypes}).
196225 */
197226 public static create ( options : ApplicationFailureOptions ) : ApplicationFailure {
198- const { message, type, nonRetryable = false , details, nextRetryDelay, cause } = options ;
199- return new this ( message , type , nonRetryable , details , cause , nextRetryDelay ) ;
227+ const { message, type, nonRetryable = false , details, nextRetryDelay, cause, category } = options ;
228+ return new this ( message , type , nonRetryable , details , cause , nextRetryDelay , category ) ;
200229 }
201230
202231 /**
@@ -261,6 +290,12 @@ export interface ApplicationFailureOptions {
261290 * Cause of the failure
262291 */
263292 cause ?: Error ;
293+
294+ /**
295+ * Severity category of the application error.
296+ * Affects worker-side logging and metrics behavior of this failure.
297+ */
298+ category ?: ApplicationFailureCategory ;
264299}
265300
266301/**
0 commit comments