-
Notifications
You must be signed in to change notification settings - Fork 4
Moved workbench-metrics from rawls #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* Implicit expansion for HttpMethod. | ||
*/ | ||
implicit object HttpMethodExpansion extends Expansion[HttpMethod] { | ||
override def makeName(m: HttpMethod): String = m.value.toLowerCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note this used to be m.toString.toLowerCase
but that results in httpMethod(get)
in akka-http, which is ugly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
trait InstrumentationDirectives extends WorkbenchInstrumented { | ||
def instrumentRequest: Directive0 = extractRequest flatMap { request => | ||
val timeStamp = System.currentTimeMillis | ||
mapResponse { response => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requestInstance
-> extractRequest
and mapHttpResponse
-> mapResponse
for spray -> akka-http
it seems to work, according to tests.
## workbench-metrics | ||
|
||
Coming soon! | ||
Contains utilities for instrumenting Scala code and reporting to StatsD using [metrics-scala](https://github.com/erikvanoosten/metrics-scala) and [metrics-statsd](https://github.com/ReadyTalk/metrics-statsd). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the code in this module is agnostic to the backend reporter -- our code is just concerned with writing to the in-memory MetricRegistry
(provided by metrics-scala/dropwizard). Then we happen to use metrics-scala
to pull off the MetricsRegistry and write to statsd, but we could conceivably use something else besides statsd.
As I'm thinking about this -- the workbench-metrics
includes the metrics-statsd
dependency but it's only used in Rawls here. So technically we could remove the metrics-statsd
dependency from workbench-metrics
. But since we're standardizing on statsd, it might be better to leave it in this module for convenience sake.
Sorry for the long-winded way of saying "this is fine".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funnily enough I was wondering if that block of code in Rawls should be moved up into this library. We should decide one way or another if this library should be "drop in and you get statsd reporting" or "drop in and you get metrics but wire up your own backend", and do whichever the right thing is based on that.
Opinions? I lean toward the former.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point - I also like the idea of moving
def startStatsDReporter(host: String, port: Int, period: java.time.Duration): Unit = {
logger.info(s"Starting statsd reporter writing to [$host:$port] with period [${period.getSeconds} seconds]")
val reporter = StatsDReporter.forRegistry(SharedMetricRegistries.getOrCreate("default"))
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build(host, port)
reporter.start(period.getSeconds, period.getSeconds, TimeUnit.SECONDS)
}
into this library somewhere. It would be a convenience for other modules depending on this library (they wouldn't need to wire up statsd themselves).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything else that needs to be yanked over?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's it in terms of existing code.
One other thought, Rawls has this config:
metrics {
prefix = "{{$environment}}.firecloud.rawls"
includeHostname = false
reporters {
# statsd commented out until it's available in the docker container
statsd {
host = "statsd"
port = 8126
period = 1m
}
}
}
Currently it's all parsed in Boot.scala
, but maybe we could make a MetricsConfig
case class and put it in workbench-metrics
. Maybe even add logic for parsing it from a .conf file, though I'm not sure if we should assume all modules are using typesafe-config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's reasonable to let users fill in startStatsDReporter
themselves. Similarly providing prefix etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good to me -- cool that the spray->akka-http conversion didn't require too many changes besides renaming stuff.
PR checklist
If you're doing a major or minor version bump to any libraries:
project/Settings.scala
createVersion()
CHANGELOG.md
for those libraries@deprecated
instead of deleting code where possibleIn all cases:
After merging, even if you haven't bumped the version:
README.md
and theCHANGELOG.md
for any libs you changed with the new dependency string. The git hash is the same short version you see in GitHub (i.e. seven characters). You can commit these changes straight to develop.