-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b10d63
commit f3fab0b
Showing
7 changed files
with
18 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
play/src/main/scala/io/opentracing/play/IpAddressTagger.scala
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
play/src/main/scala/io/opentracing/play/RemoteSpanTagger.scala
This file was deleted.
Oops, something went wrong.
16 changes: 12 additions & 4 deletions
16
play/src/main/scala/io/opentracing/play/StandardSpanTagger.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
package io.opentracing.play | ||
|
||
import com.google.common.net.InetAddresses | ||
import io.opentracing.Span | ||
import io.opentracing.tag.Tags | ||
import java.net.{Inet4Address, Inet6Address} | ||
import java.nio.ByteBuffer | ||
import play.api.mvc.{RequestHeader, Result} | ||
import scala.util.Try | ||
|
||
/** | ||
* Applies standard tags | ||
* @see https://raw.githubusercontent.com/opentracing/specification/1.0/data_conventions.yaml | ||
*/ | ||
class StandardSpanTagger(name: Option[String] = None) extends SpanTagger { | ||
class StandardSpanTagger extends SpanTagger { | ||
def tag(span: Span, request: RequestHeader, result: Result) = { | ||
name.foreach(Tags.PEER_SERVICE.set(span, _)) | ||
Tags.HTTP_METHOD.set(span, request.method) | ||
Tags.HTTP_STATUS.set(span, result.header.status) | ||
Tags.HTTP_URL.set(span, request.uri) | ||
Tags.PEER_HOSTNAME.set(span, request.domain) | ||
//Tags.PEER_PORT.set(span, request.host.split(":").lift(1).fold(if (request.secure) 443.toShort else 80.toShort)(_.toShort)) | ||
request.headers.get("X-Forwarded-Port").flatMap(port => Try(port.toInt.toShort).toOption) | ||
.foreach(Tags.PEER_PORT.set(span, _)) | ||
Try(InetAddresses.forString(request.remoteAddress)).foreach { | ||
case ip: Inet4Address => Tags.PEER_HOST_IPV4.set(span, ByteBuffer.wrap(ip.getAddress).getInt) | ||
case ip: Inet6Address => Tags.PEER_HOST_IPV6.set(span, ip.getHostAddress.takeWhile(_ != "%")) | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters