Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 48
additional cw-metrics#298
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
ammokhov
merged 3 commits into
aws-cloudformation:master
from
ammokhov:metrics-dashboardAug 21, 2020
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21 src/main/java/software/amazon/cloudformation/LambdaWrapper.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
2 changes: 2 additions & 0 deletions
2 src/main/java/software/amazon/cloudformation/metrics/Metric.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
9 changes: 9 additions & 0 deletions
9 src/main/java/software/amazon/cloudformation/metrics/MetricsPublisher.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
21 changes: 21 additions & 0 deletions
21 src/main/java/software/amazon/cloudformation/metrics/MetricsPublisherImpl.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 |
|---|---|---|
| @@ -66,6 +66,27 @@ public void publishExceptionMetric(final Instant timestamp, | ||
| publishMetric(Metric.METRIC_NAME_HANDLER_EXCEPTION, dimensions, StandardUnit.COUNT, 1.0, timestamp); | ||
| } | ||
| @Override | ||
| public void publishExceptionByErrorCodeMetric(final Instant timestamp, | ||
| final Action action, | ||
| final HandlerErrorCode handlerErrorCode, | ||
| final boolean thrown) { | ||
| Map<String, String> dimensions = new HashMap<>(); | ||
| dimensions.put(Metric.DIMENSION_KEY_ACTION_TYPE, action == null ? "NO_ACTION" : action.name()); | ||
| dimensions.put(Metric.DIMENSION_KEY_HANDLER_ERROR_CODE, handlerErrorCode.name()); | ||
ammokhov marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| publishMetric(Metric.METRIC_NAME_HANDLER_EXCEPTION_BY_ERROR_CODE, dimensions, StandardUnit.COUNT, thrown ? 1.0 : 0.0, | ||
| timestamp); | ||
| } | ||
| public void publishExceptionCountMetric(final Instant timestamp, final Action action, final boolean thrown) { | ||
| Map<String, String> dimensions = new HashMap<>(); | ||
| dimensions.put(Metric.DIMENSION_KEY_ACTION_TYPE, action == null ? "NO_ACTION" : action.name()); | ||
ammokhov marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| publishMetric(Metric.METRIC_NAME_HANDLER_EXCEPTION_BY_EXCEPTION_COUNT, dimensions, StandardUnit.COUNT, thrown ? 1.0 : 0.0, | ||
| timestamp); | ||
| } | ||
| @Override | ||
| public void publishProviderLogDeliveryExceptionMetric(final Instant timestamp, final Throwable e) { | ||
| Map<String, String> dimensions = new HashMap<>(); | ||
13 changes: 13 additions & 0 deletions
13 src/main/java/software/amazon/cloudformation/proxy/MetricsPublisherProxy.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
33 changes: 26 additions & 7 deletions
33 src/test/java/software/amazon/cloudformation/LambdaWrapperTest.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 |
|---|---|---|
| @@ -158,12 +158,15 @@ public void invokeHandler_nullResponse_returnsFailure(final String requestDataPa | ||
| verifyInitialiseRuntime(); | ||
| // validation failure metric should be published for final error handling | ||
| verify(providerMetricsPublisher, times(1)).publishExceptionMetric(any(Instant.class), any(), | ||
| any(TerminalException.class), any(HandlerErrorCode.class)); | ||
| verify(providerMetricsPublisher).publishExceptionMetric(any(Instant.class), any(), any(TerminalException.class), | ||
| any(HandlerErrorCode.class)); | ||
| verify(providerMetricsPublisher).publishExceptionByErrorCodeMetric(any(Instant.class), any(), | ||
| any(HandlerErrorCode.class), eq(Boolean.TRUE)); | ||
| verify(providerMetricsPublisher).publishExceptionCountMetric(any(Instant.class), any(), any(Boolean.class)); | ||
| // all metrics should be published even on terminal failure | ||
| verify(providerMetricsPublisher, times(1)).publishInvocationMetric(any(Instant.class), eq(action)); | ||
| verify(providerMetricsPublisher, times(1)).publishDurationMetric(any(Instant.class), eq(action), anyLong()); | ||
| verify(providerMetricsPublisher).publishInvocationMetric(any(Instant.class), eq(action)); | ||
| verify(providerMetricsPublisher).publishDurationMetric(any(Instant.class), eq(action), anyLong()); | ||
| // verify that model validation occurred for CREATE/UPDATE/DELETE | ||
| if (action == Action.CREATE || action == Action.UPDATE || action == Action.DELETE) { | ||
| @@ -399,14 +402,21 @@ public void invokeHandler_InProgress_returnsInProgress(final String requestDataP | ||
| // verify output response | ||
| verifyHandlerResponse(out, ProgressEvent.<TestModel, TestContext>builder().status(OperationStatus.IN_PROGRESS) | ||
| .resourceModel(TestModel.builder().property1("abc").property2(123).build()).build()); | ||
| verify(providerMetricsPublisher, atLeastOnce()).publishExceptionByErrorCodeMetric(any(Instant.class), eq(action), | ||
ammokhov marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| any(), eq(Boolean.FALSE)); | ||
| verify(providerMetricsPublisher).publishExceptionCountMetric(any(Instant.class), eq(action), eq(Boolean.FALSE)); | ||
| } else { | ||
| verifyHandlerResponse(out, | ||
| ProgressEvent.<TestModel, TestContext>builder().status(OperationStatus.FAILED) | ||
| .errorCode(HandlerErrorCode.InternalFailure).message("READ and LIST handlers must return synchronously.") | ||
| .build()); | ||
| verify(providerMetricsPublisher, times(1)).publishExceptionMetric(any(Instant.class), eq(action), | ||
| verify(providerMetricsPublisher).publishExceptionMetric(any(Instant.class), eq(action), | ||
| any(TerminalException.class), eq(HandlerErrorCode.InternalFailure)); | ||
| verify(providerMetricsPublisher).publishExceptionByErrorCodeMetric(any(Instant.class), eq(action), | ||
| eq(HandlerErrorCode.InternalFailure), eq(Boolean.TRUE)); | ||
| verify(providerMetricsPublisher).publishExceptionCountMetric(any(Instant.class), eq(action), eq(Boolean.TRUE)); | ||
| } | ||
| // validation failure metric should not be published | ||
| verifyNoMoreInteractions(providerMetricsPublisher); | ||
| @@ -446,8 +456,11 @@ public void reInvokeHandler_InProgress_returnsInProgress(final String requestDat | ||
| verifyInitialiseRuntime(); | ||
| // all metrics should be published, once for a single invocation | ||
| verify(providerMetricsPublisher, times(1)).publishInvocationMetric(any(Instant.class), eq(action)); | ||
| verify(providerMetricsPublisher, times(1)).publishDurationMetric(any(Instant.class), eq(action), anyLong()); | ||
| verify(providerMetricsPublisher).publishInvocationMetric(any(Instant.class), eq(action)); | ||
| verify(providerMetricsPublisher).publishDurationMetric(any(Instant.class), eq(action), anyLong()); | ||
| verify(providerMetricsPublisher, atLeastOnce()).publishExceptionByErrorCodeMetric(any(Instant.class), eq(action), | ||
| any(), eq(Boolean.FALSE)); | ||
| verify(providerMetricsPublisher).publishExceptionCountMetric(any(Instant.class), eq(action), eq(Boolean.FALSE)); | ||
| // validation failure metric should not be published | ||
| verifyNoMoreInteractions(providerMetricsPublisher); | ||
| @@ -798,6 +811,12 @@ public void invokeHandler_metricPublisherThrowable_returnsFailureResponse() thro | ||
| // verify initialiseRuntime was called and initialised dependencies | ||
| verifyInitialiseRuntime(); | ||
| verify(providerMetricsPublisher).publishExceptionByErrorCodeMetric(any(Instant.class), any(Action.class), | ||
| any(HandlerErrorCode.class), any(Boolean.class)); | ||
| verify(providerMetricsPublisher).publishExceptionCountMetric(any(Instant.class), any(Action.class), | ||
| any(Boolean.class)); | ||
| // no further calls to metrics publisher should occur | ||
| verifyNoMoreInteractions(providerMetricsPublisher); | ||
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.
This line can be removed. We actually want to do forEach for all ErrorCode, not match in what cases.
In case of in a Failed cases, this will only emit metric 1 for the one equals to the ErrorCode, but won't emit 0 metric for other metrics.