All Downloads are FREE. Search and download functionalities are using the official Maven repository.

acing_2.12.0.1.1.source-code.Span.scala Maven / Gradle / Ivy

There is a newer version: 0.1.2
Show newest version
package xyz.driver.tracing

import java.time._
import java.util.UUID

case class Span(
    name: String,
    traceId: UUID = UUID.randomUUID(),
    spanId: UUID = UUID.randomUUID(),
    parentSpanId: Option[UUID] = None,
    labels: Map[String, String] = Map.empty,
    startTime: Instant = Instant.now,
    endTime: Instant = Instant.now
) {

  def start(clock: Clock = Clock.systemUTC): Span =
    this.copy(startTime = clock.instant())
  def end(clock: Clock = Clock.systemUTC): Span =
    this.copy(endTime = clock.instant())

  def withLabels(extraLabels: (String, String)*) =
    this.copy(labels = this.labels ++ extraLabels)

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy