Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactorings and make the units for the metrics servlet configurable
- Loading branch information
Showing
19 changed files
with
182 additions
and
148 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
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
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
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
36 changes: 36 additions & 0 deletions
36
src/groovy/org/grails/plugins/yammermetrics/groovy/MetricsServletContextInitializer.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,36 @@ | ||
package org.grails.plugins.yammermetrics.groovy | ||
|
||
import com.codahale.metrics.MetricRegistry | ||
import com.codahale.metrics.servlets.MetricsServlet | ||
import grails.util.Holders | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
class MetricsServletContextInitializer extends MetricsServlet.ContextListener { | ||
|
||
public final MetricRegistry metricRegistry = new MetricRegistry() | ||
|
||
@Override | ||
protected MetricRegistry getMetricRegistry() { | ||
return metricRegistry | ||
} | ||
|
||
@Override | ||
protected TimeUnit getRateUnit() { | ||
return getUnitFromConfig("rateUnit") | ||
} | ||
|
||
@Override | ||
protected TimeUnit getDurationUnit() { | ||
return getUnitFromConfig("durationUnit") | ||
} | ||
|
||
private TimeUnit getUnitFromConfig(String propertyName) { | ||
def unit = Holders.config.yammermetrics.servlet[propertyName] | ||
if (unit instanceof String) { | ||
return TimeUnit.valueOf(unit.toUpperCase(Locale.US)) | ||
} | ||
return null | ||
} | ||
|
||
} |
14 changes: 0 additions & 14 deletions
14
src/groovy/org/grails/plugins/yammermetrics/groovy/MetricsServletContextListener.groovy
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.