You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As it has been suggested in MP Metrics, it would be cool to have a new type of metric for an error rate. The API could look something like this:
publicinterfaceErrorRateextendsMetric {
voidaddError();
voidaddSuccess();
/** The values since the application started */ErrorRateSnapshotgetTotal();
/** The values since the last snapshot */ErrorRateSnapshotgetSnapshot();
staticErrorRatecreate() {
returnnewErrorRateImpl();
}
}
publicinterfaceErrorRateSnapshot {
longgetErrors();
longgetSuccesses();
defaultdoublegetErrorRate() {
return ((double) getErrors()) / getCount();
}
defaultlonggetCount() {
returngetErrors() + getSuccesses();
}
}
@Inherited@Documented@InterceptorBinding@Retention(RUNTIME)
@Target({TYPE, CONSTRUCTOR, METHOD, ANNOTATION_TYPE})
public @interface ErrorRated {
/** * Create a default class so the value is not required to be set all the time. */classDEFAULTimplementsErrorRateHandler<Object> {
@OverridepublicbooleanisError(Objectvalue) {
returnfalse;
}
@OverridepublicbooleanisError(Throwablethrowable) {
returntrue;
}
}
/** * Specify the error rate handler class to be used. The type parameter of the fallback class must be assignable to the * return type of the annotated method. * * @see #applyOn() * @see #skipOn() */@NonbindingClass<? extendsErrorRateHandler<?>> value() defaultDEFAULT.class;
/** * The name of the meter. */@NonbindingStringname() default"";
/** * The tags of the meter. Each {@code String} tag must be in the form of 'key=value'. If the input is empty or does * not contain a '=' sign, the entry is ignored. * * @see org.eclipse.microprofile.metrics.Metadata */@NonbindingString[] tags() default {};
/** * If {@code true}, use the given name as an absolute name. If {@code false} (default), use the given name * relative to the annotated class. When annotating a class, this must be {@code false}. */@Nonbindingbooleanabsolute() defaultfalse;
/** * The display name of the meter. * * @see org.eclipse.microprofile.metrics.Metadata */@NonbindingStringdisplayName() default"";
/** * The description of the meter. * * @see org.eclipse.microprofile.metrics.Metadata */@NonbindingStringdescription() default"";
/** * The list of exception types which should be considered errors, including subclasses. * <p> * Only if an exception is <em>not</em> in this list, the {@link ErrorRateHandler} is considered. * * @see #value() */@NonbindingClass<? extendsThrowable>[] applyOn() default {};
/** * The list of exception types which should <em>not</em> be considered errors, including subclasses. * <p> * Only if an exception is <em>not</em> in this list, the {@link ErrorRateHandler} is considered. * * @see #value() */@NonbindingClass<? extendsThrowable>[] skipOn() default {};
}
WDYT? I could do a PR.
The text was updated successfully, but these errors were encountered:
As it has been suggested in MP Metrics, it would be cool to have a new type of metric for an error rate. The API could look something like this:
WDYT? I could do a PR.
The text was updated successfully, but these errors were encountered: