-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the endpoint /metrics for Prometheus. (#175)
Executor and Timeseries metrics in Prometheus format. Small refactorings in Executor.scala, Timeseries.scala, App.scala.
- Loading branch information
eryshev
authored
Oct 2, 2017
1 parent
b4548d0
commit f5d6d8e
Showing
9 changed files
with
146 additions
and
40 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
2 changes: 1 addition & 1 deletion
2
...ain/scala/com/criteo/cuttle/Logging.scala → ...main/scala/com/criteo/cuttle/Logger.scala
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,4 +1,4 @@ | ||
package com.criteo.cuttle.logging | ||
package com.criteo.cuttle | ||
|
||
trait Logger { | ||
def debug(message: => String): Unit | ||
|
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,27 @@ | ||
package com.criteo.cuttle | ||
|
||
object Metrics { | ||
sealed trait Metric { | ||
def toString: String | ||
} | ||
|
||
case class Gauge(name: String, value: Long, tags: Seq[(String, String)] = Seq.empty) extends Metric | ||
|
||
trait MetricProvider { | ||
def getMetrics(jobs: Set[String]): Seq[Metric] | ||
} | ||
|
||
private[cuttle] object Prometheus { | ||
def format(metrics: Seq[Metric]): String = { | ||
val prometheusMetrics = metrics.map { | ||
case Gauge(name, value, tags) => | ||
s"$name${ | ||
if (tags.nonEmpty) s" {${tags.map(tag => s"""${tag._1}="${tag._2}"""").mkString(", ")}}" | ||
else "" | ||
} $value" | ||
} | ||
|
||
s"${prometheusMetrics.mkString("\n")}\n" | ||
} | ||
} | ||
} |
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