Does tracing of a Option[Span] => Future[A] based on the given trace name and annotations (annotations are sent at the beginning).
Does tracing of a Option[Span] => Future[A] based on the given trace name and annotations (annotations are sent at the beginning). The Option[Span] parameter is so that you can pass the span details to other systems in your Future-producing function.
This function expects that there is a parent Span in scope. Even if there is a Span in scope, it may not be used as a Parent Span if it does not have the proper ids, namely a span id and a trace id. In this case, a new scope with the given name and new ids will be used and it will not have a parent id.
If the in scope ZipkinServiceLike does not provide a Span for the in scope parentSpan Span (or if it fails) your function will be handed a None.
Note, the Span given to your function should not be mutated to affect tracing. It is a deep copy anyways, so there will be no effect.
Example:
val myTracedFuture = TracedFuture("slowHttpCall") { maybeSpan => val forwardHeaders = maybeSpan.fold(Seq.empty[(String,String)]){ toHttpHeaders } WS.url("myServer").withHeaders(forwardHeaders:_*) }
the name for the span used for tracing
variable list of annotations to send for tracing in the beginning (after the client sent annotation)
the function that will take an Option[Span] and produce a Future[A]. It is an Option[Span] because there is a chance the ZipkinServiceLike will either fail or not produce a Span at all due to filtering or sampling.
Does tracing of a Option[Span] => Future[(A, Seq[(String, String)]] based on the given trace name and annotations (annotations are sent at the beginning).
Does tracing of a Option[Span] => Future[(A, Seq[(String, String)]] based on the given trace name and annotations (annotations are sent at the beginning). The Option[Span] parameter is so that you can pass the span details to other systems in your Future-producing function. Note that this function expects the a Future Tuple2 result, where the second element in the pair is a Seq[(String, String)] set of annotations that you might want to use in order to set final annotations on the span.
This function expects that there is a parent Span in scope. Even if there is a Span in scope, it may not be used as a Parent Span if it does not have the proper ids, namely a span id and a trace id. In this case, a new scope with the given name and new ids will be used and it will not have a parent id.
If the in scope ZipkinServiceLike does not provide a Span for the in scope parentSpan Span (or if it fails) your function will be handed a None.
Note, the Span given to your function should not be mutated to affect tracing. It is a deep copy anyways, so there will be no effect.
Example:
val myTracedFuture = TracedFuture.endAnnotations("slowHttpCall") { maybeSpan => val forwardHeaders = maybeSpan.fold(Seq.empty[(String,String)]){ toHttpHeaders } WS.url("myServer").withHeaders(forwardHeaders:_*).map { response => (response.json, Seq("session id" -> response.header("session id").toString)) } }
the name for the span used for tracing
variable list of annotations to send for tracing in the beginning (after the client sent annotation)
the function that will take an Option[Span] and produce a Future[(A, Seq[(String, String)])]. It is an Option[Span] because there is a chance the ZipkinServiceLike will either fail or not produce a Span at all due to filtering or sampling. The Seq[(String, String)] will be used as annotations to be sent right before setting client received and sending the Span.
Helpers for Tracing futures with Zipkin.