@@ -158,12 +158,15 @@ public void invokeHandler_nullResponse_returnsFailure(final String requestDataPa
158158 verifyInitialiseRuntime ();
159159
160160 // validation failure metric should be published for final error handling
161- verify (providerMetricsPublisher , times (1 )).publishExceptionMetric (any (Instant .class ), any (),
162- any (TerminalException .class ), any (HandlerErrorCode .class ));
161+ verify (providerMetricsPublisher ).publishExceptionMetric (any (Instant .class ), any (), any (TerminalException .class ),
162+ any (HandlerErrorCode .class ));
163+ verify (providerMetricsPublisher ).publishExceptionByErrorCodeMetric (any (Instant .class ), any (),
164+ any (HandlerErrorCode .class ), eq (Boolean .TRUE ));
165+ verify (providerMetricsPublisher ).publishExceptionCountMetric (any (Instant .class ), any (), any (Boolean .class ));
163166
164167 // all metrics should be published even on terminal failure
165- verify (providerMetricsPublisher , times ( 1 ) ).publishInvocationMetric (any (Instant .class ), eq (action ));
166- verify (providerMetricsPublisher , times ( 1 ) ).publishDurationMetric (any (Instant .class ), eq (action ), anyLong ());
168+ verify (providerMetricsPublisher ).publishInvocationMetric (any (Instant .class ), eq (action ));
169+ verify (providerMetricsPublisher ).publishDurationMetric (any (Instant .class ), eq (action ), anyLong ());
167170
168171 // verify that model validation occurred for CREATE/UPDATE/DELETE
169172 if (action == Action .CREATE || action == Action .UPDATE || action == Action .DELETE ) {
@@ -399,14 +402,21 @@ public void invokeHandler_InProgress_returnsInProgress(final String requestDataP
399402 // verify output response
400403 verifyHandlerResponse (out , ProgressEvent .<TestModel , TestContext >builder ().status (OperationStatus .IN_PROGRESS )
401404 .resourceModel (TestModel .builder ().property1 ("abc" ).property2 (123 ).build ()).build ());
405+ verify (providerMetricsPublisher , atLeastOnce ()).publishExceptionByErrorCodeMetric (any (Instant .class ), eq (action ),
406+ any (), eq (Boolean .FALSE ));
407+ verify (providerMetricsPublisher ).publishExceptionCountMetric (any (Instant .class ), eq (action ), eq (Boolean .FALSE ));
402408 } else {
403409 verifyHandlerResponse (out ,
404410 ProgressEvent .<TestModel , TestContext >builder ().status (OperationStatus .FAILED )
405411 .errorCode (HandlerErrorCode .InternalFailure ).message ("READ and LIST handlers must return synchronously." )
406412 .build ());
407- verify (providerMetricsPublisher , times ( 1 ) ).publishExceptionMetric (any (Instant .class ), eq (action ),
413+ verify (providerMetricsPublisher ).publishExceptionMetric (any (Instant .class ), eq (action ),
408414 any (TerminalException .class ), eq (HandlerErrorCode .InternalFailure ));
415+ verify (providerMetricsPublisher ).publishExceptionByErrorCodeMetric (any (Instant .class ), eq (action ),
416+ eq (HandlerErrorCode .InternalFailure ), eq (Boolean .TRUE ));
417+ verify (providerMetricsPublisher ).publishExceptionCountMetric (any (Instant .class ), eq (action ), eq (Boolean .TRUE ));
409418 }
419+
410420 // validation failure metric should not be published
411421 verifyNoMoreInteractions (providerMetricsPublisher );
412422
@@ -446,8 +456,11 @@ public void reInvokeHandler_InProgress_returnsInProgress(final String requestDat
446456 verifyInitialiseRuntime ();
447457
448458 // all metrics should be published, once for a single invocation
449- verify (providerMetricsPublisher , times (1 )).publishInvocationMetric (any (Instant .class ), eq (action ));
450- verify (providerMetricsPublisher , times (1 )).publishDurationMetric (any (Instant .class ), eq (action ), anyLong ());
459+ verify (providerMetricsPublisher ).publishInvocationMetric (any (Instant .class ), eq (action ));
460+ verify (providerMetricsPublisher ).publishDurationMetric (any (Instant .class ), eq (action ), anyLong ());
461+ verify (providerMetricsPublisher , atLeastOnce ()).publishExceptionByErrorCodeMetric (any (Instant .class ), eq (action ),
462+ any (), eq (Boolean .FALSE ));
463+ verify (providerMetricsPublisher ).publishExceptionCountMetric (any (Instant .class ), eq (action ), eq (Boolean .FALSE ));
451464
452465 // validation failure metric should not be published
453466 verifyNoMoreInteractions (providerMetricsPublisher );
@@ -798,6 +811,12 @@ public void invokeHandler_metricPublisherThrowable_returnsFailureResponse() thro
798811 // verify initialiseRuntime was called and initialised dependencies
799812 verifyInitialiseRuntime ();
800813
814+ verify (providerMetricsPublisher ).publishExceptionByErrorCodeMetric (any (Instant .class ), any (Action .class ),
815+ any (HandlerErrorCode .class ), any (Boolean .class ));
816+
817+ verify (providerMetricsPublisher ).publishExceptionCountMetric (any (Instant .class ), any (Action .class ),
818+ any (Boolean .class ));
819+
801820 // no further calls to metrics publisher should occur
802821 verifyNoMoreInteractions (providerMetricsPublisher );
803822
0 commit comments