levkhomich / akka-tracing

A distributed tracing extension for Akka. Provides integration with Play framework, Spray and Akka HTTP.
Other
307 stars 32 forks source link

InvalidClassException on TracingAnnotations$ServerReceived; no valid constructor #94

Closed Akrome closed 7 years ago

Akrome commented 7 years ago

Hi. I'm having issues reproducing the basic level of tracing within my project. I'm using Akka 2.4.11 's Java API, and the 0.6 version of the library from maven.

Right after I call trace.finish(), I receive this StackTrace and no message reaches Zipkin (Zipkin is configured correctly since it works with the activator example):

java.io.InvalidClassException: com.github.levkhomich.akka.tracing.TracingAnnotations$ServerReceived$; no valid constructor
    at java.io.ObjectStreamClass$ExceptionInfo.newInvalidClassException(ObjectStreamClass.java:150) ~[?:1.8.0_121]
    at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:790) ~[?:1.8.0_121]
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1987) ~[?:1.8.0_121]
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535) ~[?:1.8.0_121]
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2231) ~[?:1.8.0_121]
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2155) ~[?:1.8.0_121]
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2013) ~[?:1.8.0_121]
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535) ~[?:1.8.0_121]
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422) ~[?:1.8.0_121]
    at akka.serialization.JavaSerializer$$anonfun$1.apply(Serializer.scala:295) ~[akka-actor_2.11-2.4.11.jar:?]
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58) ~[scala-library-2.11.8.jar:?]
    at akka.serialization.JavaSerializer.fromBinary(Serializer.scala:295) ~[akka-actor_2.11-2.4.11.jar:?]
    at akka.serialization.Serialization$$anonfun$deserialize$3.apply(Serialization.scala:193) ~[akka-actor_2.11-2.4.11.jar:?]
    at scala.util.Try$.apply(Try.scala:192) ~[scala-library-2.11.8.jar:?]
    at akka.serialization.Serialization.deserialize(Serialization.scala:193) ~[akka-actor_2.11-2.4.11.jar:?]
    at akka.actor.dungeon.Dispatch$class.sendMessage(Dispatch.scala:140) ~[akka-actor_2.11-2.4.11.jar:?]
    at akka.actor.ActorCell.sendMessage(ActorCell.scala:374) ~[akka-actor_2.11-2.4.11.jar:?]
    at akka.actor.Cell$class.sendMessage(ActorCell.scala:295) ~[akka-actor_2.11-2.4.11.jar:?]
    at akka.actor.ActorCell.sendMessage(ActorCell.scala:374) ~[akka-actor_2.11-2.4.11.jar:?]
    at akka.actor.RepointableActorRef.$bang(RepointableActorRef.scala:171) ~[akka-actor_2.11-2.4.11.jar:?]
    at com.github.levkhomich.akka.tracing.TracingExtensionImpl.sample(TracingExtension.scala:327) ~[akka-tracing-core_2.11-0.6.jar:0.6]
    at com.github.levkhomich.akka.tracing.TracingExtensionImpl.sample(TracingExtension.scala:315) ~[akka-tracing-core_2.11-0.6.jar:0.6]
    at com.github.levkhomich.akka.tracing.TracingExtensionImpl.sample(TracingExtension.scala:201) ~[akka-tracing-core_2.11-0.6.jar:0.6]
    at (line where i call trace.finish() ).

This is my current config section for tracing and serializers:

 akka.tracing {
    # use this option to disable tracing
    #enabled = true
    host = localhost
    # zipkin collector or scribe host name

    # collector's port
    #    port = 9410 # default, can be omitted

    # every n'th message should be traced
    # for example, 1 means that every message would be traced, 2 - half of messages, 4 - a fourth part, etc.
    sample-rate = 1
  }

akka.actor.serializers {
      kryo = "com.romix.akka.serialization.kryo.KryoSerializer"
      tracing = "com.github.levkhomich.akka.tracing.serialization.BaseTracingSupportSerializer"
    }

 akka.actor.serialization-bindings {
      "java.util.Map" = kryo
      "java.util.Collection" = kryo
      "com.github.levkhomich.akka.tracing.TracingSupport" = tracing
      "com.github.levkhomich.akka.tracing.japi.TracingSupport" = tracing
    }

The last line I reach inside the library is line 327 of TracingExtension.scala:

holder ! Sample(initialAnnotation, tracingId, m, service, rpc, System.nanoTime)

where the initialAnnotation is ServerReceived.

Any help on how to configure the serializers for this to work?

levkhomich commented 7 years ago

Sorry for late response.

The message you are referring to is supposed to be local and, therefore, not serialized. So it seems that your akka system is serializing all messages (most likely due to akka.actor.serialize-messages = on).

Akrome commented 7 years ago

You are right, I had that enabled. I don't have access to the codebase for testing it now, but most likely that was the cause.