added metric for pubsub

This commit is contained in:
Athou
2013-06-27 09:50:11 +02:00
parent dbc1e0b538
commit 9c6f75b633
2 changed files with 37 additions and 3 deletions

View File

@@ -57,6 +57,15 @@ public class MetricsBean {
thisMinute.statusesInserted += statusesCount;
}
public void pushReceived(int feedCount) {
thisHour.pushNotificationsReceived++;
thisMinute.pushNotificationsReceived++;
thisHour.pushFeedsQueued += feedCount;
thisMinute.pushFeedsQueued += feedCount;
}
public void threadWaited() {
thisHour.threadWaited++;
thisMinute.threadWaited++;
@@ -83,6 +92,8 @@ public class MetricsBean {
private int entriesInserted;
private int statusesInserted;
private int threadWaited;
private int pushNotificationsReceived;
private int pushFeedsQueued;
public int getFeedsRefreshed() {
return feedsRefreshed;
@@ -124,5 +135,21 @@ public class MetricsBean {
this.threadWaited = threadWaited;
}
public int getPushNotificationsReceived() {
return pushNotificationsReceived;
}
public void setPushNotificationsReceived(int pushNotificationsReceived) {
this.pushNotificationsReceived = pushNotificationsReceived;
}
public int getPushFeedsQueued() {
return pushFeedsQueued;
}
public void setPushFeedsQueued(int pushFeedsQueued) {
this.pushFeedsQueued = pushFeedsQueued;
}
}
}

View File

@@ -21,6 +21,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.commafeed.backend.MetricsBean;
import com.commafeed.backend.dao.FeedDAO;
import com.commafeed.backend.feeds.FeedParser;
import com.commafeed.backend.feeds.FeedRefreshTaskGiver;
@@ -50,6 +51,9 @@ public class PubSubHubbubCallbackREST {
@Inject
ApplicationSettingsService applicationSettingsService;
@Inject
MetricsBean metricsBean;
@Path("/callback")
@GET
@Produces(MediaType.TEXT_PLAIN)
@@ -58,8 +62,9 @@ public class PubSubHubbubCallbackREST {
@QueryParam("hub.challenge") String challenge,
@QueryParam("hub.lease_seconds") String leaseSeconds,
@QueryParam("hub.verify_token") String verifyToken) {
Preconditions.checkState(applicationSettingsService.get().isPubsubhubbub());
Preconditions.checkState(applicationSettingsService.get()
.isPubsubhubbub());
Preconditions.checkArgument(StringUtils.isNotEmpty(topic));
Preconditions.checkArgument("subscribe".equals(mode));
@@ -85,7 +90,8 @@ public class PubSubHubbubCallbackREST {
@POST
@Consumes({ MediaType.APPLICATION_ATOM_XML, "application/rss+xml" })
public Response callback() {
Preconditions.checkState(applicationSettingsService.get().isPubsubhubbub());
Preconditions.checkState(applicationSettingsService.get()
.isPubsubhubbub());
try {
byte[] bytes = IOUtils.toByteArray(request.getInputStream());
FetchedFeed fetchedFeed = parser.parse(null, bytes);
@@ -97,6 +103,7 @@ public class PubSubHubbubCallbackREST {
log.debug("pushing content to queue for {}", feed.getUrl());
taskGiver.add(feed);
}
metricsBean.pushReceived(feeds.size());
}
} catch (Exception e) {
log.error("Could not parse pubsub callback: " + e.getMessage());