val XKey = Key.broadcastString("x-key")
val context =
Kamon.currentContext().get(XKey) match {
case None =>
Kamon.currentContext().withKey(XKey, Some("XKey Value"))
case _ => Kamon.currentContext()
}
Kamon.withContext(context) {
for {
result <- httpClient(Get(uri))
} yield result
}
Kamon.init()
as the very first operation in your code. I am deploying my service as a war, and I'm getting an java.lang.reflect.InvocationTargetException
when I call it in the Context Listener. Where should I be calling it?Hi! Is there a way to specify custom bucket limits? for example i used seconds Kamon.histogram("tsr-last-trained-point", MeasurementUnit.time.seconds)
and i get buckets like this
tsr_last_trained_point_seconds_bucket{le="0.005",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="0.01",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="0.025",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="0.05",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="0.075",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="0.1",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="0.25",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="0.5",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="0.75",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="1.0",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="2.5",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="5.0",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="7.5",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="10.0",granularity="HOUR"} 0.0
tsr_last_trained_point_seconds_bucket{le="+Inf",granularity="HOUR"} 50.0
tsr_last_trained_point_seconds_count{granularity="HOUR"} 50.0
tsr_last_trained_point_seconds_sum{granularity="HOUR"} 102740.0
But i want buckets like 3600 (hour), 86100(day), week and etc... How can i define histogram like this?
I already got kamon working using the full ?kamon-bundle
but I can see that it adds a lot of dependencies which I dont need/want.
Whats the best way to pick only the things I need put still get the same auto instrumentation as if I would use the full bundle?
Lets say I only want to use: kamon-executors
, kamon-scala-future
, kamon-cassandra
.
I think I could just exclude all other modules via libraryExclusions
but imo the other way around, including only what I want, would be better.
build.sbt
and saw that the kamon-bundle
dependsOn
a lot of modules and I mistakenly assumed that all those modules would be automatically pulled in if I add kamon-bundle
as a dependency to my project.kamon-bundle
and kamon-core
beeing pulled in if I just specify kamon-bundle
as a dependecy. So it looks fine.Counter
, Gauge
etc more advanced or is it just a matter of additional abstraction over the actual metrics implementation which is beneficial?
using kamon to report metrics from a play application (play 2.6.6)
libraryDependencies += "io.kamon" %% "kamon-bundle" % "2.1.0"
libraryDependencies += "io.kamon" %% "kamon-prometheus" % "2.1.0"
I create a custom metric that captures number of requests per customer account (there are a handful of those). I want to get the method called, and the http response status for each request. I initialize it:code
private val requestsByAccountCounter = Kamon.counter("requests_by_account")
I have an ActionBuilder where I increment the counter
requestsByAccountCounter.withTag("account", accountInHeader(request))
.withTag("method", s"${uriBaseFromPath(request.path)}")
.withTag("http_status", r.header.status).increment()
3 metrics are generated
requests_by_account_total{account="TestAccountId"} 0.0
requests_by_account_total{account="TestAccountId",method="/data/catalog"} 0.0
requests_by_account_total{account="TestAccountId",http_status="200",method="/data/catalog"} 34.0
I know I can increment each tag, but ideally I'd like only the 3rd metric to be generated.
How can I accomplish that?