Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of upgrade to metrics 3.0.1
- Loading branch information
Showing
17 changed files
with
127 additions
and
63 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
import com.codahale.metrics.health.HealthCheckRegistry | ||
import metricstest.AlwaysHealthyCheck | ||
import org.grails.plugins.yammermetrics.groovy.HealthCheckServletContextListener | ||
|
||
class BootStrap { | ||
|
||
def init = { servletContext -> | ||
HealthCheckRegistry healthCheckRegistry = HealthCheckServletContextListener.HEALTH_CHECK_REGISTRY | ||
healthCheckRegistry.register("AlwaysHealthyCheck", new AlwaysHealthyCheck()) | ||
} | ||
|
||
def destroy = { | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
example-app/src/groovy/metricstest/AlwaysHealthyCheck.groovy
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,11 @@ | ||
package metricstest | ||
|
||
import com.codahale.metrics.health.HealthCheck | ||
|
||
class AlwaysHealthyCheck extends HealthCheck { | ||
|
||
@Override | ||
protected HealthCheck.Result check() throws Exception { | ||
return HealthCheck.Result.healthy() | ||
} | ||
} |
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
18 changes: 9 additions & 9 deletions
18
src/groovy/org/grails/plugins/yammermetrics/groovy/GroovierMetrics.groovy
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 |
---|---|---|
@@ -1,25 +1,25 @@ | ||
package org.grails.plugins.yammermetrics.groovy | ||
|
||
import com.yammer.metrics.Metrics | ||
import com.codahale.metrics.MetricRegistry | ||
import org.codehaus.groovy.reflection.ReflectionUtils | ||
|
||
import java.util.concurrent.TimeUnit | ||
class GroovierMetrics { | ||
static MetricRegistry DEFAULT_METRICS_REGISTRY = new MetricRegistry() | ||
|
||
class GroovierMetrics extends Metrics { | ||
// ignore org.springsource.loaded.ri.ReflectiveInterceptor when not running as a war, and ignore this class for convenience | ||
static final List<String> extraIgnoredPackages = ["org.springsource.loaded.ri", "org.grails.plugins.yammermetrics.groovy"] | ||
|
||
private GroovierMetrics() { super() } | ||
|
||
static com.yammer.metrics.core.Meter newMeter(String meterName){ | ||
return newMeter(ReflectionUtils.getCallingClass(0, extraIgnoredPackages), meterName, meterName, TimeUnit.SECONDS) | ||
static com.codahale.metrics.Meter newMeter(String meterName){ | ||
return DEFAULT_METRICS_REGISTRY.meter(MetricRegistry.name(ReflectionUtils.getCallingClass(0, extraIgnoredPackages), meterName)) | ||
} | ||
|
||
static com.yammer.metrics.core.Timer newTimer(String timerName){ | ||
return newTimer(ReflectionUtils.getCallingClass(0, extraIgnoredPackages), timerName ) | ||
static com.codahale.metrics.Timer newTimer(String timerName){ | ||
return DEFAULT_METRICS_REGISTRY.timer(MetricRegistry.name(ReflectionUtils.getCallingClass(0, extraIgnoredPackages), timerName)) | ||
} | ||
|
||
static com.yammer.metrics.core.Timer newTimer(String className, String timerName){ | ||
return newTimer(Class.forName(className), timerName) | ||
static com.codahale.metrics.Timer newTimer(String className, String timerName){ | ||
return DEFAULT_METRICS_REGISTRY.timer(MetricRegistry.name(className, timerName)) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/groovy/org/grails/plugins/yammermetrics/groovy/HealthCheckServletContextListener.groovy
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,14 @@ | ||
package org.grails.plugins.yammermetrics.groovy | ||
|
||
import com.codahale.metrics.health.HealthCheckRegistry | ||
import com.codahale.metrics.servlets.HealthCheckServlet | ||
|
||
class HealthCheckServletContextListener extends HealthCheckServlet.ContextListener { | ||
|
||
public static final HealthCheckRegistry HEALTH_CHECK_REGISTRY = new HealthCheckRegistry() | ||
|
||
@Override | ||
protected HealthCheckRegistry getHealthCheckRegistry() { | ||
return HealthCheckServletContextListener.HEALTH_CHECK_REGISTRY | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/groovy/org/grails/plugins/yammermetrics/groovy/MetricsServletContextListener.groovy
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,12 @@ | ||
package org.grails.plugins.yammermetrics.groovy | ||
|
||
import com.codahale.metrics.MetricRegistry | ||
import com.codahale.metrics.servlets.MetricsServlet | ||
|
||
class MetricsServletContextListener extends MetricsServlet.ContextListener { | ||
|
||
@Override | ||
protected MetricRegistry getMetricRegistry() { | ||
return GroovierMetrics.DEFAULT_METRICS_REGISTRY | ||
} | ||
} |
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
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
15 changes: 8 additions & 7 deletions
15
src/groovy/org/grails/plugins/yammermetrics/reporting/GrailsAdminServlet.groovy
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 |
---|---|---|
@@ -1,15 +1,16 @@ | ||
package org.grails.plugins.yammermetrics.reporting | ||
|
||
import com.yammer.metrics.reporting.AdminServlet | ||
import com.yammer.metrics.reporting.MetricsServlet | ||
import com.yammer.metrics.reporting.PingServlet | ||
import com.yammer.metrics.reporting.ThreadDumpServlet | ||
import com.codahale.metrics.servlets.AdminServlet | ||
import com.codahale.metrics.servlets.MetricsServlet | ||
import com.codahale.metrics.servlets.PingServlet | ||
import com.codahale.metrics.servlets.ThreadDumpServlet | ||
|
||
class GrailsAdminServlet extends AdminServlet { | ||
|
||
GrailsAdminServlet() { | ||
super(new GrailsHealthCheckServlet(), new MetricsServlet(), new PingServlet(), | ||
new ThreadDumpServlet(), AdminServlet.DEFAULT_HEALTHCHECK_URI, AdminServlet.DEFAULT_METRICS_URI, | ||
AdminServlet.DEFAULT_PING_URI, AdminServlet.DEFAULT_THREADS_URI); | ||
super() | ||
// super(new GrailsHealthCheckServlet(), new MetricsServlet(), new PingServlet(), | ||
// new ThreadDumpServlet(), AdminServlet.DEFAULT_HEALTHCHECK_URI, AdminServlet.DEFAULT_METRICS_URI, | ||
// AdminServlet.DEFAULT_PING_URI, AdminServlet.DEFAULT_THREADS_URI); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
.../yamme/metrics/groovy/SampleObject.groovy → ...dahale/metrics/groovy/SampleObject.groovy
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
Oops, something went wrong.