Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Merge branch '0.2.x' into 0.3.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/com/github/stijndehaes/playprometheusfilters/PrometheusModule.scala
#	build.sbt
  • Loading branch information
stijndehaes committed Aug 13, 2017
2 parents 9e6fe1f + d13008b commit 7a930a6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import io.prometheus.client.CollectorRegistry

class PrometheusModule extends Module {

override def bindings(environment: Environment, configuration: Configuration): Seq[Binding[_]] = Seq(
bind[CollectorRegistry].to(CollectorRegistry.defaultRegistry)
)

override def bindings(environment: Environment, configuration: Configuration): Seq[Binding[_]] = {
CollectorRegistry.defaultRegistry.clear()
Seq(
bind[CollectorRegistry].to(CollectorRegistry.defaultRegistry)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import javax.inject._
import play.api.mvc._
import io.prometheus.client.CollectorRegistry
import io.prometheus.client.exporter.common.TextFormat
import org.slf4j.LoggerFactory
import play.api.http.HttpEntity

class PrometheusController @Inject()(registry: CollectorRegistry, cc: ControllerComponents) extends AbstractController(cc) {

private val logger = LoggerFactory.getLogger(classOf[PrometheusController])

def getMetrics = Action {
logger.trace("Metrics call received")
val samples = new StringBuilder()
val writer = new WriterAdapter(samples)
TextFormat.write004(writer, registry.metricFamilySamples())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.github.stijndehaes.playprometheusfilters.filters

import akka.stream.Materializer
import com.google.inject.Inject
import com.google.inject.{Inject, Singleton}
import io.prometheus.client.{Collector, CollectorRegistry, Histogram}
import play.api.mvc.{Filter, RequestHeader, Result}
import play.api.routing.Router

import scala.concurrent.{ExecutionContext, Future}

@Singleton
class StatusAndRouteLatencyFilter @Inject()(registry: CollectorRegistry) (implicit val mat: Materializer, ec: ExecutionContext) extends Filter {

private[filters] val requestLatency = Histogram.build
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name := "play-prometheus-filters"
organization := "com.github.stijndehaes"

version := "0.3.0"
version := "0.3.1"

lazy val root = (project in file("."))
.enablePlugins(PlayScala)
Expand Down

0 comments on commit 7a930a6

Please sign in to comment.