Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Supplies a JAX-RS Provider for metrics-jersey that uses SharedMetricR…
…egistries (so our @timed, @metered, etc. work) Supplies a ContextListener to set the attributes that metrics-servlet expects, so we no longer need to provide our own MetricsServlet.
- Loading branch information
Edwin Shin
committed
May 30, 2013
1 parent
1ce5819
commit 1afe622
Showing
5 changed files
with
60 additions
and
88 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/org/fcrepo/metrics/MetricsContextListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
package org.fcrepo.metrics; | ||
|
||
import static org.fcrepo.metrics.RegistryService.getMetrics; | ||
|
||
import javax.servlet.ServletContext; | ||
import javax.servlet.ServletContextEvent; | ||
import javax.servlet.ServletContextListener; | ||
import javax.servlet.annotation.WebListener; | ||
|
||
import com.codahale.metrics.health.HealthCheckRegistry; | ||
|
||
/** | ||
* A ServletContextListener to set the ServletContext attributes that the | ||
* Metrics servlets expect. | ||
* | ||
* @author Edwin Shin | ||
* @see <a href="http://metrics.codahale.com/manual/servlets/">http://metrics.codahale.com/manual/servlets/</a> | ||
*/ | ||
@WebListener | ||
public class MetricsContextListener implements ServletContextListener { | ||
|
||
@Override | ||
public void contextInitialized(ServletContextEvent event) { | ||
ServletContext context = event.getServletContext(); | ||
context.setAttribute( | ||
"com.codahale.metrics.servlets.MetricsServlet.registry", | ||
getMetrics()); | ||
|
||
context.setAttribute( | ||
"com.codahale.metrics.servlets.HealthCheckServlet.registry", | ||
new HealthCheckRegistry()); | ||
} | ||
|
||
@Override | ||
public void contextDestroyed(ServletContextEvent event) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.fcrepo.metrics; | ||
|
||
import javax.ws.rs.ext.Provider; | ||
|
||
import com.codahale.metrics.jersey.InstrumentedResourceMethodDispatchAdapter; | ||
|
||
@Provider | ||
public class MetricsProvider extends InstrumentedResourceMethodDispatchAdapter { | ||
|
||
public MetricsProvider() { | ||
super(RegistryService.getMetrics()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters