-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMetricsPublisherProxy.java
More file actions
64 lines (55 loc) · 2.95 KB
/
Copy pathMetricsPublisherProxy.java
File metadata and controls
64 lines (55 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 software.amazon.cloudformation.proxy;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import software.amazon.cloudformation.Action;
import software.amazon.cloudformation.metrics.MetricsPublisher;
public class MetricsPublisherProxy {
private final List<MetricsPublisher> metricsPublishers = new ArrayList<>();
public void addMetricsPublisher(final MetricsPublisher metricsPublisher) {
metricsPublishers.add(metricsPublisher);
}
public void publishExceptionMetric(final Instant timestamp,
final Action action,
final Throwable e,
final HandlerErrorCode handlerErrorCode) {
metricsPublishers.stream()
.forEach(metricsPublisher -> metricsPublisher.publishExceptionMetric(timestamp, action, e, handlerErrorCode));
}
public void publishExceptionByErrorCodeMetric(final Instant timestamp,
final Action action,
final HandlerErrorCode handlerErrorCode,
final boolean thrown) {
metricsPublishers.stream().forEach(
metricsPublisher -> metricsPublisher.publishExceptionByErrorCodeMetric(timestamp, action, handlerErrorCode, thrown));
}
public void publishExceptionCountMetric(final Instant timestamp, final Action action, final boolean thrown) {
metricsPublishers.stream()
.forEach(metricsPublisher -> metricsPublisher.publishExceptionCountMetric(timestamp, action, thrown));
}
public void publishInvocationMetric(final Instant timestamp, final Action action) {
metricsPublishers.stream().forEach(metricsPublisher -> metricsPublisher.publishInvocationMetric(timestamp, action));
}
public void publishDurationMetric(final Instant timestamp, final Action action, final long milliseconds) {
metricsPublishers.stream()
.forEach(metricsPublisher -> metricsPublisher.publishDurationMetric(timestamp, action, milliseconds));
}
public void publishProviderLogDeliveryExceptionMetric(final Instant timestamp, final Throwable exception) {
metricsPublishers.stream()
.forEach(metricsPublisher -> metricsPublisher.publishProviderLogDeliveryExceptionMetric(timestamp, exception));
}
}