summaryrefslogtreecommitdiff
path: root/src/com/p4square/grow/GrowProcessComponent.java
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2014-10-04 12:10:19 -0700
committerJesse Morgan <jesse@jesterpm.net>2014-10-04 12:10:19 -0700
commit755c48f80d45a3fbd5557e8e856f24f496512de6 (patch)
tree0198a8392ef939c6c045a8a715a5b23a6df1c45a /src/com/p4square/grow/GrowProcessComponent.java
parentaa0f29bb6e4ab179b18e4b373a1fb8a3b840b594 (diff)
Adding metrics.
Diffstat (limited to 'src/com/p4square/grow/GrowProcessComponent.java')
-rw-r--r--src/com/p4square/grow/GrowProcessComponent.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/com/p4square/grow/GrowProcessComponent.java b/src/com/p4square/grow/GrowProcessComponent.java
index 791f177..f63538c 100644
--- a/src/com/p4square/grow/GrowProcessComponent.java
+++ b/src/com/p4square/grow/GrowProcessComponent.java
@@ -6,6 +6,10 @@ package com.p4square.grow;
import java.io.File;
import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import com.codahale.metrics.ConsoleReporter;
+import com.codahale.metrics.MetricRegistry;
import org.apache.log4j.Logger;
@@ -21,6 +25,7 @@ import com.p4square.grow.backend.BackendVerifier;
import com.p4square.grow.backend.GrowBackend;
import com.p4square.grow.config.Config;
import com.p4square.grow.frontend.GrowFrontend;
+import com.p4square.restlet.metrics.MetricsApplication;
/**
*
@@ -32,6 +37,7 @@ public class GrowProcessComponent extends Component {
private static final String BACKEND_REALM = "Grow Backend";
private final Config mConfig;
+ private final MetricRegistry mMetricRegistry;
/**
* Create a new Grow Process website component combining a frontend and backend.
@@ -50,12 +56,15 @@ public class GrowProcessComponent extends Component {
mConfig = config;
mConfig.updateConfig(this.getClass().getResourceAsStream("/grow.properties"));
+ // Prepare Metrics
+ mMetricRegistry = new MetricRegistry();
+
// Frontend
- GrowFrontend frontend = new GrowFrontend(mConfig);
+ GrowFrontend frontend = new GrowFrontend(mConfig, mMetricRegistry);
getDefaultHost().attach(frontend);
// Backend
- GrowBackend backend = new GrowBackend(mConfig);
+ GrowBackend backend = new GrowBackend(mConfig, mMetricRegistry);
getInternalRouter().attach("/backend", backend);
// Authenticated access to the backend
@@ -64,6 +73,13 @@ public class GrowProcessComponent extends Component {
false, ChallengeScheme.HTTP_BASIC, BACKEND_REALM, verifier);
auth.setNext(backend);
getDefaultHost().attach("/backend", auth);
+
+ // Authenticated access to metrics
+ ChallengeAuthenticator metricAuth = new ChallengeAuthenticator(
+ getContext().createChildContext(), false,
+ ChallengeScheme.HTTP_BASIC, BACKEND_REALM, verifier);
+ metricAuth.setNext(new MetricsApplication(mMetricRegistry));
+ getDefaultHost().attach("/metrics", metricAuth);
}