aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: d33ed1fce4fa5d3242935123cdeef88475d60443 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Driver Tracing Library

A vendor-neutral tracing library for Akka-HTTP.

This library provides tracing directives for Akka-HTTP. It specifies
common client abstractions and implementations that may be used with
different tracing solutions, such as Google Stackdriver Tracing.

## Getting Started

Driver tracing is published to maven central as a standard Scala
library. Include it in sbt by adding the following snippet to your
build.sbt:

```scala
libraryDependencies += "xyz.driver" %% "tracing" % "0.0.1"
```

### Example
```scala
import xyz.driver.tracing._
import xyz.driver.tracing.TracingDirectives._

val tracer = new LoggingTracer(println)

val route =
  // report how long any request to this service takes
  trace(tracer) {
    path("my-service-endpoint") {
	  get {
	    // include a sub-trace with a custom name
	    trace(tracer, Some("complex-call")) {
		  // do something that takes time
		  complete("done")
	    }
	  }
    } ~
    path("proxy-service-endpoint") {
	  // extract tracing headers so they may be injected into nested requests
	  extractTraceHeaders{ headers =>
	    // call external service with the existing parent tracing headers
		complete("done")
	  }
    }
  }

```

## Tracing Backends

### Logging
TODO

### Google Stackdriver Tracing
https://cloud.google.com/trace/docs/reference/v1/rest/v1/projects.traces#Trace
TODO