diff options
Diffstat (limited to 'kamon-core/src/main/scala/kamon/trace')
-rw-r--r-- | kamon-core/src/main/scala/kamon/trace/Span.scala | 9 | ||||
-rw-r--r-- | kamon-core/src/main/scala/kamon/trace/Tracer.scala | 13 |
2 files changed, 11 insertions, 11 deletions
diff --git a/kamon-core/src/main/scala/kamon/trace/Span.scala b/kamon-core/src/main/scala/kamon/trace/Span.scala index e012d46a..a23c1f49 100644 --- a/kamon-core/src/main/scala/kamon/trace/Span.scala +++ b/kamon-core/src/main/scala/kamon/trace/Span.scala @@ -136,13 +136,16 @@ class Span(spanContext: SpanContext, initialOperationName: String, initialTags: override def finish(): Unit = finish(Clock.microTimestamp()) - override def finish(finishMicros: Long): Unit = - if(isOpen) { + override def finish(finishMicros: Long): Unit = synchronized { + if (isOpen) { isOpen = false endTimestampMicros = finishMicros recordSpanMetrics() - reporterRegistry.reportSpan(completedSpan) + + if(sampled) + reporterRegistry.reportSpan(completedSpan) } + } private def completedSpan: Span.CompletedSpan = Span.CompletedSpan(spanContext, operationName, startTimestampMicros, endTimestampMicros, tags, logs) diff --git a/kamon-core/src/main/scala/kamon/trace/Tracer.scala b/kamon-core/src/main/scala/kamon/trace/Tracer.scala index 734f82b2..65d8edb7 100644 --- a/kamon-core/src/main/scala/kamon/trace/Tracer.scala +++ b/kamon-core/src/main/scala/kamon/trace/Tracer.scala @@ -28,15 +28,18 @@ import kamon.metric.MetricLookup import kamon.util.Clock -class Tracer(metrics: MetricLookup, reporterRegistry: ReporterRegistryImpl) extends io.opentracing.Tracer { +class Tracer(metrics: MetricLookup, reporterRegistry: ReporterRegistryImpl, initialConfig: Config) + extends ThreadLocalActiveSpanSource with io.opentracing.Tracer { + private val logger = Logger(classOf[Tracer]) private val tracerMetrics = new TracerMetrics(metrics) - private val activeSpanSource = new ThreadLocalActiveSpanSource() @volatile private var configuredSampler: Sampler = Sampler.never @volatile private var textMapSpanContextCodec = SpanContextCodec.TextMap @volatile private var httpHeaderSpanContextCodec = SpanContextCodec.ZipkinB3 + reconfigure(initialConfig) + override def buildSpan(operationName: String): io.opentracing.Tracer.SpanBuilder = new SpanBuilder(operationName) @@ -57,12 +60,6 @@ class Tracer(metrics: MetricLookup, reporterRegistry: ReporterRegistryImpl) exte def sampler: Sampler = configuredSampler - override def activeSpan(): io.opentracing.ActiveSpan = - activeSpanSource.activeSpan() - - override def makeActive(span: io.opentracing.Span): io.opentracing.ActiveSpan = - activeSpanSource.makeActive(span) - def setTextMapSpanContextCodec(codec: SpanContextCodec[TextMap]): Unit = this.textMapSpanContextCodec = codec |