tendrilinc / scala-finagle

OpenTracing Instrumentation for Finagle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Coverage Status Released Version Apache-2.0 license

OpenTracing Finagle Instrumentation

OpenTracing instrumentation for Finagle.

Installation

build.sbt

libraryDependencies += "io.opentracing.contrib" % "opentracing-finagle" % "0.0.2"

Usage

// Instantiate tracer
val tracer: Tracer = ...

Http Server

// Apply OpenTracingHttpFilter to Finagle service to serve HTTP requests
val service = new OpenTracingHttpFilter(tracer, true) andThen new Service[http.Request, http.Response] {
    def apply(req: http.Request): Future[http.Response] =
      Future.value(
        http.Response(req.version, http.Status.Ok)
      )
  }
  
// Create server   
val server = Http.server.serve(":8080", service)
Await.ready(server)

Http Client

// Apply OpenTracingHttpFilter to Finagle client service 
val client = new OpenTracingHttpFilter(tracer, false) andThen Http.client.newService(":8080")

// Build request
val request = http.Request(http.Method.Get, "/")

// Build response
val response: Future[http.Response] = client(request)

// Wait for result
val result = Await.result(response)

Changes

  • Downgrade scala to 2.11 since that is what we use at Tendril
  • Propagate tracing info through Futures and Locals so we can get a full trace
  • Use the scala-tracing-integrations library to share tracing info around the program

License

Apache 2.0 License.

About

OpenTracing Instrumentation for Finagle

License:Apache License 2.0


Languages

Language:Scala 63.5%Language:Shell 36.5%