Skip to content

evolution-gaming/stracer

Repository files navigation

STracer

Build Status Coverage Status Codacy Badge Version License: MIT

Library for distributed tracing in Scala

Span

final case class Span(
  traceId: TraceId,
  spanId: SpanId,
  name: String,
  timestamp: Instant,
  kind: Option[Kind] = None,
  duration: Option[FiniteDuration] = None,
  remoteEndpoint: Option[Endpoint] = None,
  tags: Tags = List.empty,
  shared: Option[Boolean] = None,
  parentId: Option[SpanId])

Trace

final case class Trace(
  traceId: TraceId,
  spanId: SpanId,
  parentId: Option[SpanId],
  timestamp: Option[Instant],
  sampling: Option[Sampling] = None)

Tracer

Generate SpanId and Trace

trait Tracer[F[_]] {

  def trace(sampling: Option[Sampling] = None): F[Option[Trace]]
}

ReportSpan

We provide Kafka based implementation, which uses SpanBytesEncoder.THRIFT from Zipkin to encode spans. It is also compatible with Jaeger & Ingester
Since version 5.0.0 this implementation is available in separate module stracer-kafka.

trait ReportSpan[F[_]] {

  def apply(span: Span): F[Unit]
}

Setup

addSbtPlugin("com.evolution" % "sbt-artifactory-plugin" % "0.0.2")

libraryDependencies += "com.evolutiongaming" %% "stracer"           % "5.0.0"
libraryDependencies += "com.evolutiongaming" %% "stracer-play-json" % "5.0.0"
libraryDependencies += "com.evolutiongaming" %% "stracer-circe"     % "5.0.0"
libraryDependencies += "com.evolutiongaming" %% "stracer-kafka"     % "5.0.0"