levkhomich / akka-tracing

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

Akka-http page is missing in Wiki #87

Open relgames opened 7 years ago

relgames commented 7 years ago

https://github.com/levkhomich/akka-tracing/wiki There is no page for akka-http. So it is not clear how to trace requests with akka-http and Java.

levkhomich commented 7 years ago

Nice catch, thank you. I will take care of it.

Generally speaking, it should be used in the same way as Spray tooling from Scala. I do not know anyone who is interested in using it from Java, so there is no support for it yet.

relgames commented 7 years ago

I'm interested :) I use akka-http from Java.

raam86 commented 7 years ago

Would love a scala page for akka-http. I'm currently doing

class Routes(sys: ActorSystem) extends BaseTracingDirectives{

override def trace: TracingExtensionImpl = TracingExtension(sys)
  //Routes go here
}

I am not using actors explictly and bind like this:

val bindingFuture = Http().bindAndHandle(new Routes(system).routes, "0.0.0.0", 8080)
tonypizzicato commented 7 years ago

@raam86 can you provide complete usage example with routes definition and wiring it with tracing support? can't make it work with json requests as i must provide unmarshaller/marshaller for tracedHandleWith

raam86 commented 7 years ago

@tonypizzicato my route looks like this:

 val tracedPlaces = (am: ActorMaterializer) => path("tplace") {
      get {
        implicit val aq = am
        tracedHandleWith("place")(processPlace)
      }
  }

make sure you return the correct types from the handle with function. processPlace signature:

def processPlace(place: PlaceRequestParameters)(implicit am: ActorMaterializer): Future[JsObject]
rojanu commented 7 years ago

I am stuck as well.
I have

get {
  import com.mdsol.strategicmonitoring.visits.model.views.ClientViewsJsonProtocol._
  path(uri / JavaUUID) { uuid =>
    tracedHandleWith(systemName) {
      extractUserUUID { userUuid =>
        logger.info(s"Get visit")
        complete(
          visitsService.findByUuid(userUuid, uuid).map {
            case visit@Some(_) =>
              logger.info(s"Visit retrieved")
              OK -> visit
            case _ => NotFound -> None
          }
        )
      }
    }
  }
}

for above route it requires an implicit FromRequestUnmarshaller. What is the idea? Do I need to provide a class with TracingSupport, e.g. TestMessage class in the tests, for all of my routes then try to unmarshall something like TestMessage for each request ?