Work toward fixing ONOS-1138: Batching topo event may cause event loss
Added another metric to the onos-app-metrics-topology application to collect and display the number and rate of the Reasons for the Topology Events. Example: onos> topology-events-metrics ... Topology Graph Event Timestamp (ms from epoch)=1426699861509 Topology Graph Events count=6 rate(events/sec) mean=0.002315 m1=0.000000 m5=0.000004 m15=0.000378 Topology Graph Reasons Event Timestamp (ms from epoch)=1426699861509 Topology Graph Reasons Events count=9 rate(events/sec) mean=0.003472 m1=0.000000 m5=0.000005 m15=0.000567 The corresponding object names in the JSON output are: topologyGraphReasonsEventRate topologyGraphReasonsEventTimestamp Change-Id: Ib1aeb83c38b3b72d0ae8a4f49bc1e14badc0199d
Showing
3 changed files
with
30 additions
and
5 deletions
... | @@ -91,17 +91,20 @@ public class TopologyMetrics implements TopologyMetricsService { | ... | @@ -91,17 +91,20 @@ public class TopologyMetrics implements TopologyMetricsService { |
91 | private static final String FEATURE_HOST_NAME = "HostEvent"; | 91 | private static final String FEATURE_HOST_NAME = "HostEvent"; |
92 | private static final String FEATURE_LINK_NAME = "LinkEvent"; | 92 | private static final String FEATURE_LINK_NAME = "LinkEvent"; |
93 | private static final String FEATURE_GRAPH_NAME = "GraphEvent"; | 93 | private static final String FEATURE_GRAPH_NAME = "GraphEvent"; |
94 | + private static final String FEATURE_GRAPH_REASONS_NAME = "GraphReasonsEvent"; | ||
94 | // | 95 | // |
95 | // Event metrics: | 96 | // Event metrics: |
96 | // - Device events | 97 | // - Device events |
97 | // - Host events | 98 | // - Host events |
98 | // - Link events | 99 | // - Link events |
99 | // - Topology Graph events | 100 | // - Topology Graph events |
101 | + // - Topology Graph Reasons events | ||
100 | // | 102 | // |
101 | private EventMetric topologyDeviceEventMetric; | 103 | private EventMetric topologyDeviceEventMetric; |
102 | private EventMetric topologyHostEventMetric; | 104 | private EventMetric topologyHostEventMetric; |
103 | private EventMetric topologyLinkEventMetric; | 105 | private EventMetric topologyLinkEventMetric; |
104 | private EventMetric topologyGraphEventMetric; | 106 | private EventMetric topologyGraphEventMetric; |
107 | + private EventMetric topologyGraphReasonsEventMetric; | ||
105 | 108 | ||
106 | @Activate | 109 | @Activate |
107 | protected void activate() { | 110 | protected void activate() { |
... | @@ -160,6 +163,11 @@ public class TopologyMetrics implements TopologyMetricsService { | ... | @@ -160,6 +163,11 @@ public class TopologyMetrics implements TopologyMetricsService { |
160 | return topologyGraphEventMetric; | 163 | return topologyGraphEventMetric; |
161 | } | 164 | } |
162 | 165 | ||
166 | + @Override | ||
167 | + public EventMetric topologyGraphReasonsEventMetric() { | ||
168 | + return topologyGraphReasonsEventMetric; | ||
169 | + } | ||
170 | + | ||
163 | /** | 171 | /** |
164 | * Records an event. | 172 | * Records an event. |
165 | * | 173 | * |
... | @@ -226,6 +234,7 @@ public class TopologyMetrics implements TopologyMetricsService { | ... | @@ -226,6 +234,7 @@ public class TopologyMetrics implements TopologyMetricsService { |
226 | log.debug("Topology Event: time = {} type = {} event = {}", | 234 | log.debug("Topology Event: time = {} type = {} event = {}", |
227 | event.time(), event.type(), event); | 235 | event.time(), event.type(), event); |
228 | for (Event reason : event.reasons()) { | 236 | for (Event reason : event.reasons()) { |
237 | + recordEvent(event, topologyGraphReasonsEventMetric); | ||
229 | log.debug("Topology Event Reason: time = {} type = {} event = {}", | 238 | log.debug("Topology Event Reason: time = {} type = {} event = {}", |
230 | reason.time(), reason.type(), reason); | 239 | reason.time(), reason.type(), reason); |
231 | } | 240 | } |
... | @@ -257,11 +266,15 @@ public class TopologyMetrics implements TopologyMetricsService { | ... | @@ -257,11 +266,15 @@ public class TopologyMetrics implements TopologyMetricsService { |
257 | topologyGraphEventMetric = | 266 | topologyGraphEventMetric = |
258 | new EventMetric(metricsService, COMPONENT_NAME, | 267 | new EventMetric(metricsService, COMPONENT_NAME, |
259 | FEATURE_GRAPH_NAME); | 268 | FEATURE_GRAPH_NAME); |
269 | + topologyGraphReasonsEventMetric = | ||
270 | + new EventMetric(metricsService, COMPONENT_NAME, | ||
271 | + FEATURE_GRAPH_REASONS_NAME); | ||
260 | 272 | ||
261 | topologyDeviceEventMetric.registerMetrics(); | 273 | topologyDeviceEventMetric.registerMetrics(); |
262 | topologyHostEventMetric.registerMetrics(); | 274 | topologyHostEventMetric.registerMetrics(); |
263 | topologyLinkEventMetric.registerMetrics(); | 275 | topologyLinkEventMetric.registerMetrics(); |
264 | topologyGraphEventMetric.registerMetrics(); | 276 | topologyGraphEventMetric.registerMetrics(); |
277 | + topologyGraphReasonsEventMetric.registerMetrics(); | ||
265 | } | 278 | } |
266 | 279 | ||
267 | /** | 280 | /** |
... | @@ -272,5 +285,6 @@ public class TopologyMetrics implements TopologyMetricsService { | ... | @@ -272,5 +285,6 @@ public class TopologyMetrics implements TopologyMetricsService { |
272 | topologyHostEventMetric.removeMetrics(); | 285 | topologyHostEventMetric.removeMetrics(); |
273 | topologyLinkEventMetric.removeMetrics(); | 286 | topologyLinkEventMetric.removeMetrics(); |
274 | topologyGraphEventMetric.removeMetrics(); | 287 | topologyGraphEventMetric.removeMetrics(); |
288 | + topologyGraphReasonsEventMetric.removeMetrics(); | ||
275 | } | 289 | } |
276 | } | 290 | } | ... | ... |
... | @@ -26,35 +26,42 @@ public interface TopologyMetricsService { | ... | @@ -26,35 +26,42 @@ public interface TopologyMetricsService { |
26 | /** | 26 | /** |
27 | * Gets the last saved topology events. | 27 | * Gets the last saved topology events. |
28 | * | 28 | * |
29 | - * @return the last saved topology events. | 29 | + * @return the last saved topology events |
30 | */ | 30 | */ |
31 | public List<Event> getEvents(); | 31 | public List<Event> getEvents(); |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * Gets the Event Metric for the Device Events. | 34 | * Gets the Event Metric for the Device Events. |
35 | * | 35 | * |
36 | - * @return the Event Metric for the Device Events. | 36 | + * @return the Event Metric for the Device Events |
37 | */ | 37 | */ |
38 | public EventMetric topologyDeviceEventMetric(); | 38 | public EventMetric topologyDeviceEventMetric(); |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Gets the Event Metric for the Host Events. | 41 | * Gets the Event Metric for the Host Events. |
42 | * | 42 | * |
43 | - * @return the Event Metric for the Host Events. | 43 | + * @return the Event Metric for the Host Events |
44 | */ | 44 | */ |
45 | public EventMetric topologyHostEventMetric(); | 45 | public EventMetric topologyHostEventMetric(); |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Gets the Event Metric for the Link Events. | 48 | * Gets the Event Metric for the Link Events. |
49 | * | 49 | * |
50 | - * @return the Event Metric for the Link Events. | 50 | + * @return the Event Metric for the Link Events |
51 | */ | 51 | */ |
52 | public EventMetric topologyLinkEventMetric(); | 52 | public EventMetric topologyLinkEventMetric(); |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * Gets the Event Metric for the Topology Graph Events. | 55 | * Gets the Event Metric for the Topology Graph Events. |
56 | * | 56 | * |
57 | - * @return the Event Metric for the Topology Graph Events. | 57 | + * @return the Event Metric for the Topology Graph Events |
58 | */ | 58 | */ |
59 | public EventMetric topologyGraphEventMetric(); | 59 | public EventMetric topologyGraphEventMetric(); |
60 | + | ||
61 | + /** | ||
62 | + * Gets the Event Metric for the Topology Graph Reasons Events. | ||
63 | + * | ||
64 | + * @return the Event Metric for the Topology Graph Reasons Events | ||
65 | + */ | ||
66 | + public EventMetric topologyGraphReasonsEventMetric(); | ||
60 | } | 67 | } | ... | ... |
... | @@ -60,12 +60,16 @@ public class TopologyEventsMetricsCommand extends AbstractShellCommand { | ... | @@ -60,12 +60,16 @@ public class TopologyEventsMetricsCommand extends AbstractShellCommand { |
60 | service.topologyLinkEventMetric()); | 60 | service.topologyLinkEventMetric()); |
61 | result = json(mapper, result, "topologyGraphEvent", | 61 | result = json(mapper, result, "topologyGraphEvent", |
62 | service.topologyGraphEventMetric()); | 62 | service.topologyGraphEventMetric()); |
63 | + result = json(mapper, result, "topologyGraphReasonsEvent", | ||
64 | + service.topologyGraphReasonsEventMetric()); | ||
63 | print("%s", result); | 65 | print("%s", result); |
64 | } else { | 66 | } else { |
65 | printEventMetric("Device", service.topologyDeviceEventMetric()); | 67 | printEventMetric("Device", service.topologyDeviceEventMetric()); |
66 | printEventMetric("Host", service.topologyHostEventMetric()); | 68 | printEventMetric("Host", service.topologyHostEventMetric()); |
67 | printEventMetric("Link", service.topologyLinkEventMetric()); | 69 | printEventMetric("Link", service.topologyLinkEventMetric()); |
68 | printEventMetric("Graph", service.topologyGraphEventMetric()); | 70 | printEventMetric("Graph", service.topologyGraphEventMetric()); |
71 | + printEventMetric("Graph Reasons", | ||
72 | + service.topologyGraphReasonsEventMetric()); | ||
69 | } | 73 | } |
70 | } | 74 | } |
71 | 75 | ... | ... |
-
Please register or login to post a comment