This repository was archived by the owner on Mar 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
This repository was archived by the owner on Mar 16, 2025. It is now read-only.
NullPointerException when running with recordMetrics #51
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I am trying to use the akka-http-metrics-prometheus registry
Scala Version: 2.12.11
Akka Http Version: 10.1.12
Akka Http Metrics Prometheus Version: 1.1.0
My Code looks like this
object Registry {
def apply() = {
val settings = PrometheusSettings
.default
.withDurationConfig(Buckets(1, 2, 3, 5, 8, 13, 21, 34))
.withReceivedBytesConfig(Quantiles(0.5, 0.75, 0.9, 0.95, 0.99))
.withSentBytesConfig(PrometheusSettings.DefaultQuantiles)
val prometheus = new CollectorRegistry()
PrometheusRegistry(settings = settings)
}
}
Http().bindAndHandle(routes.recordMetrics(Registry()), appConfig.server.interface, appConfig.server.port)
When i try to run any route, I am facing a NullPointerException.
Could not materialize handling flow for IncomingConnection(/127.0.0.1:8080,/127.0.0.1:64662,Flow(FlowShape(IncomingTCP.in(1710177258),GraphStages$Detacher.out(817845304))))
java.lang.NullPointerException
at scala.concurrent.impl.Promise$DefaultPromise.onComplete(Promise.scala:307)
at fr.davit.akka.http.metrics.core.HttpMetricsRegistry.onConnection(HttpMetricsRegistry.scala:126)
at fr.davit.akka.http.metrics.core.scaladsl.server.HttpMetricsRoute.$anonfun$recordMetrics$1(HttpMetricsRoute.scala:65)
at akka.stream.impl.Compose.apply(TraversalBuilder.scala:169)
at akka.stream.impl.PhasedFusingActorMaterializer.materialize(PhasedFusingActorMaterializer.scala:529)
at akka.stream.impl.PhasedFusingActorMaterializer.materialize(PhasedFusingActorMaterializer.scala:449)
at akka.stream.impl.PhasedFusingActorMaterializer.materialize(PhasedFusingActorMaterializer.scala:441)
at akka.stream.scaladsl.RunnableGraph.run(Flow.scala:703)
at akka.http.scaladsl.HttpExt.$anonfun$bindAndHandle$1(Http.scala:252)
at akka.stream.impl.fusing.MapAsyncUnordered$$anon$31.onPush(Ops.scala:1401)
at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:541)
at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:495)
at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:390)
at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:624)
at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:501)
at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:599)
at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:768)
at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:783)
at akka.actor.Actor.aroundReceive(Actor.scala:534)
at akka.actor.Actor.aroundReceive$(Actor.scala:532)
at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:690)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:573)
at akka.actor.ActorCell.invoke(ActorCell.scala:543)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:269)
at akka.dispatch.Mailbox.run(Mailbox.scala:230)
at akka.dispatch.Mailbox.exec(Mailbox.scala:242)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
I am pretty sure that i have made some sort of mistake during initialisation and hence the issue.
Would really appreciate if you can point me in the right direction.
Thanks
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working