Skip to content

opentracing-contrib/scala-finagle

Repository files navigation

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)

License

Apache 2.0 License.

About

OpenTracing Instrumentation for Finagle

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published