-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add the endpoint /api/metrics for Prometheus. #175
Changes from 10 commits
03d654f
c17870b
a035454
998215b
0c718d8
9d4df04
97f3e2f
db26da8
754d1fb
0601dac
e5aa635
eb5bcc7
e1f6c24
760243c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.criteo.cuttle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we scope all this into a |
||
|
||
sealed trait Metric { | ||
def toString: String | ||
} | ||
|
||
case class Gauge(name: String, value: Long, tags: Seq[(String, String)] = Seq.empty) extends Metric | ||
|
||
trait MetricProvider { | ||
private[cuttle] def getMetrics(jobs: Set[String]): Seq[Metric] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't be |
||
} | ||
|
||
object Prometheus { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one should be |
||
def format(metrics: Seq[Metric]): String = { | ||
val prometheusMetrics = metrics.map { | ||
case Gauge(name, value, tags) => | ||
s"$name {${if (tags.nonEmpty) tags.map(tag => s"""${tag._1}="${tag._2}"""").mkString(", ") else ""}} $value" | ||
} | ||
|
||
s"${prometheusMetrics.mkString("\n")}\n" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,10 @@ private[timeseries] object IntervalMap { | |
m <- this.intersect(interval).toList | ||
} yield m): _*)) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are adding code you do not use, If you really feel this is something that needs to be done I would suggest you could move it to another PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cleaned it |
||
def head: (Interval[A], B) = tree.head | ||
|
||
def last: (Interval[A], B) = tree.last | ||
} | ||
|
||
implicit def functorFilterInstance[K: Ordering] = | ||
|
@@ -162,4 +166,6 @@ private[timeseries] sealed trait IntervalMap[A, B] { | |
def mapKeys[K: Ordering](f: A => K): IntervalMap[K, B] | ||
def whenIsDef[C](other: IntervalMap[A, C]): IntervalMap[A, B] | ||
def whenIsUndef[C](other: IntervalMap[A, C]): IntervalMap[A, B] | ||
def head: (Interval[A], B) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
def last: (Interval[A], B) | ||
} |
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 just wanted to point out that provided figures can be inconsistent because stm accesses are non enclosed in a single
transaction. Not use this is critical though