Pavlin Radoslavov
Committed by Gerrit Code Review

Added Intent PURGED events to the collected Intent Event metrics.

Change-Id: Ibe641b91ffe68e8699d6a21a430ea772a7cb7e7a
......@@ -69,6 +69,7 @@ public class IntentMetrics implements IntentMetricsService,
private static final String FEATURE_WITHDRAW_REQUESTED_NAME =
"WithdrawRequested";
private static final String FEATURE_WITHDRAWN_NAME = "Withdrawn";
private static final String FEATURE_PURGED_NAME = "Purged";
//
// Event metrics:
// - Intent Submitted API operation
......@@ -76,12 +77,14 @@ public class IntentMetrics implements IntentMetricsService,
// - Intent Failed compilation or installation
// - Intent Withdraw Requested API operation
// - Intent Withdrawn operation completion
// - Intent Purged operation completion
//
private EventMetric intentSubmittedEventMetric;
private EventMetric intentInstalledEventMetric;
private EventMetric intentFailedEventMetric;
private EventMetric intentWithdrawRequestedEventMetric;
private EventMetric intentWithdrawnEventMetric;
private EventMetric intentPurgedEventMetric;
@Activate
protected void activate() {
......@@ -135,6 +138,11 @@ public class IntentMetrics implements IntentMetricsService,
}
@Override
public EventMetric intentPurgedEventMetric() {
return intentPurgedEventMetric;
}
@Override
public void event(IntentEvent event) {
synchronized (lastEvents) {
switch (event.type()) {
......@@ -153,6 +161,9 @@ public class IntentMetrics implements IntentMetricsService,
case WITHDRAWN:
intentWithdrawnEventMetric.eventReceived();
break;
case PURGED:
intentPurgedEventMetric.eventReceived();
break;
default:
break;
}
......@@ -198,12 +209,16 @@ public class IntentMetrics implements IntentMetricsService,
intentWithdrawnEventMetric =
new EventMetric(metricsService, COMPONENT_NAME,
FEATURE_WITHDRAWN_NAME);
intentPurgedEventMetric =
new EventMetric(metricsService, COMPONENT_NAME,
FEATURE_PURGED_NAME);
intentSubmittedEventMetric.registerMetrics();
intentInstalledEventMetric.registerMetrics();
intentFailedEventMetric.registerMetrics();
intentWithdrawRequestedEventMetric.registerMetrics();
intentWithdrawnEventMetric.registerMetrics();
intentPurgedEventMetric.registerMetrics();
}
/**
......@@ -215,5 +230,6 @@ public class IntentMetrics implements IntentMetricsService,
intentFailedEventMetric.removeMetrics();
intentWithdrawRequestedEventMetric.removeMetrics();
intentWithdrawnEventMetric.removeMetrics();
intentPurgedEventMetric.removeMetrics();
}
}
......
......@@ -26,42 +26,49 @@ public interface IntentMetricsService {
/**
* Gets the last saved intent events.
*
* @return the last saved intent events.
* @return the last saved intent events
*/
public List<IntentEvent> getEvents();
/**
* Gets the Event Metric for the intent INSTALL_REQ events.
*
* @return the Event Metric for the intent INSTALL_REQ events.
* @return the Event Metric for the intent INSTALL_REQ events
*/
public EventMetric intentSubmittedEventMetric();
/**
* Gets the Event Metric for the intent INSTALLED events.
*
* @return the Event Metric for the intent INSTALLED events.
* @return the Event Metric for the intent INSTALLED events
*/
public EventMetric intentInstalledEventMetric();
/**
* Gets the Event Metric for the intent FAILED events.
*
* @return the Event Metric for the intent FAILED events.
* @return the Event Metric for the intent FAILED events
*/
public EventMetric intentFailedEventMetric();
/**
* Gets the Event Metric for the intent WITHDRAW_REQ events.
*
* @return the Event Metric for the intent WITHDRAW_REQ events.
* @return the Event Metric for the intent WITHDRAW_REQ events
*/
public EventMetric intentWithdrawRequestedEventMetric();
/**
* Gets the Event Metric for the intent WITHDRAWN events.
*
* @return the Event Metric for the intent WITHDRAWN events.
* @return the Event Metric for the intent WITHDRAWN events
*/
public EventMetric intentWithdrawnEventMetric();
/**
* Gets the Event Metric for the intent PURGED events.
*
* @return the Event Metric for the intent PURGED events
*/
public EventMetric intentPurgedEventMetric();
}
......
......@@ -62,6 +62,8 @@ public class IntentEventsMetricsCommand extends AbstractShellCommand {
service.intentWithdrawRequestedEventMetric());
result = json(mapper, result, "intentWithdrawn",
service.intentWithdrawnEventMetric());
result = json(mapper, result, "intentPurged",
service.intentPurgedEventMetric());
print("%s", result);
} else {
printEventMetric("Submitted",
......@@ -74,6 +76,8 @@ public class IntentEventsMetricsCommand extends AbstractShellCommand {
service.intentWithdrawRequestedEventMetric());
printEventMetric("Withdrawn",
service.intentWithdrawnEventMetric());
printEventMetric("Purged",
service.intentPurgedEventMetric());
}
}
......