samstarling / finagle-prometheus

Provides a bridge between Finagle and Prometheus metrics
https://samstarling.co.uk/projects/finagle-prometheus/
MIT License
30 stars 18 forks source link

Error on start #16

Closed turbolent closed 6 years ago

turbolent commented 6 years ago

I tried integrating this library like shown in the example, but get the following error when my server starts up:

java.lang.AbstractMethodError: Method com/twitter/finagle/stats/MetricsStatsReceiver.com$twitter$finagle$stats$StatsReceiverWithCumulativeGauges$_setter_$com$twitter$finagle$stats$StatsReceiverWithCumulativeGauges$$whenDefaultNotPresent_$eq(Ljava/util/function/Function;)V is abstract
    at com.twitter.finagle.stats.MetricsStatsReceiver.com$twitter$finagle$stats$StatsReceiverWithCumulativeGauges$_setter_$com$twitter$finagle$stats$StatsReceiverWithCumulativeGauges$$whenDefaultNotPresent_$eq(MetricsStatsReceiver.scala)
    at com.twitter.finagle.stats.StatsReceiverWithCumulativeGauges.$init$(CumulativeGauge.scala:138)
    at com.twitter.finagle.stats.MetricsStatsReceiver.<init>(MetricsStatsReceiver.scala:50)
    at com.twitter.finagle.stats.MetricsStatsReceiver.<init>(MetricsStatsReceiver.scala:55)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at com.twitter.app.LoadService$.$anonfun$apply$7(LoadService.scala:73)
    at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:241)
    at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:59)
    at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:52)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
    at scala.collection.TraversableLike.flatMap(TraversableLike.scala:241)
    at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:238)
    at scala.collection.AbstractTraversable.flatMap(Traversable.scala:104)
    at com.twitter.app.LoadService$.apply(LoadService.scala:62)
    at com.twitter.finagle.util.LoadService$.apply(LoadService.scala:14)
    at com.twitter.finagle.stats.LoadedStatsReceiver$.<init>(LoadedStatsReceiver.scala:18)
    at com.twitter.finagle.stats.LoadedStatsReceiver$.<clinit>(LoadedStatsReceiver.scala)
    at com.twitter.finagle.stats.ClientStatsReceiver$.<init>(LoadedStatsReceiver.scala:55)
    at com.twitter.finagle.stats.ClientStatsReceiver$.<clinit>(LoadedStatsReceiver.scala)
    at com.twitter.finagle.client.StackClient$.<init>(StackClient.scala:368)
    at com.twitter.finagle.client.StackClient$.<clinit>(StackClient.scala)
    at com.twitter.finagle.Thrift$Client$.<init>(Thrift.scala:205)
    at com.twitter.finagle.Thrift$Client$.<clinit>(Thrift.scala)
    at com.twitter.finagle.Thrift$.client(Thrift.scala:362)
    at com.turbolent.spacyThrift.SpacyThriftClient.<init>(SpacyThriftClient.scala:10)
    at com.turbolent.questionServer.QuestionServer$.main(QuestionServer.scala:83)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.twitter.app.App.$anonfun$nonExitingMain$3(App.scala:233)
    at scala.Option.foreach(Option.scala:257)
    at com.twitter.app.App.nonExitingMain(App.scala:232)
    at com.twitter.app.App.nonExitingMain$(App.scala:210)
    at com.turbolent.questionServer.QuestionServer$.nonExitingMain(QuestionServer.scala:18)
    at com.twitter.app.App.main(App.scala:198)
    at com.twitter.app.App.main$(App.scala:196)
    at com.turbolent.questionServer.QuestionServer$.main(QuestionServer.scala:18)
    at com.turbolent.questionServer.QuestionServer.main(QuestionServer.scala)

Could the issue be that I'm using Finagle 17.12.0?

samstarling commented 6 years ago

Hey @turbolent – thanks for reporting this. I haven't had a chance to look properly yet, but this does sound like a problem with Finagle versions and compatibility. I'll try and take a look this evening, and try and get it working with the latest version of Finagle.

turbolent commented 6 years ago

Great, thank you! I'll also have a look tonight, but I don't have much experience with Finagle's metrics

samstarling commented 6 years ago

Hey @turbolent, sorry for the delay, it's been a busy week. I just raised PR #17 to bump the Finagle version to 18.2.0. The tests passed locally for me, and I'll keep an eye on the Travis CI builds.

Would you be able to provide me some example code that reproduces the issue? A snippet would work, but you might get a faster reply if it's either a project I can check out and run. You might also be able to fork this repo and add a failing test. From the stack trace, it looks like you're doing something Thrift-related – is that correct?

turbolent commented 6 years ago

Great! No worries, same here.

Trying to produce a minimal working example, it seems like just having finagle-prometheus in the classpath causes the crash. When investigating further, I also found https://github.com/finagle/finagle-postgres/issues/63. It seems like Finagle's API changed a while ago, and having different versions of it and its dependencies causes the crash. The upgrade of the library to 18.2.0 should probably fix the issue for users who use a recent version of Finagle.

samstarling commented 6 years ago

@turbolent That would make sense – I just released v0.0.5 on bintray, and it's just in the process of syncing to Maven Central. Let me know if it helps!

turbolent commented 6 years ago

Great, that seems to do the trick -- Thanks for publishing an updated release and the great library!

samstarling commented 6 years ago

Great news :+1: