From 622c8d12735c1a8de3716984686e52bc33368004 Mon Sep 17 00:00:00 2001 From: Ivan Topolnjak Date: Wed, 13 Dec 2017 23:32:30 +0100 Subject: use java.time.Instant with nanoseconds precision in the Tracer --- .../src/test/scala/kamon/trace/LocalSpanSpec.scala | 22 ++++++++++++---------- .../src/test/scala/kamon/trace/TracerSpec.scala | 6 ++++-- 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'kamon-core-tests') diff --git a/kamon-core-tests/src/test/scala/kamon/trace/LocalSpanSpec.scala b/kamon-core-tests/src/test/scala/kamon/trace/LocalSpanSpec.scala index 21ad93b3..c73e0cb5 100644 --- a/kamon-core-tests/src/test/scala/kamon/trace/LocalSpanSpec.scala +++ b/kamon-core-tests/src/test/scala/kamon/trace/LocalSpanSpec.scala @@ -15,6 +15,8 @@ package kamon.trace +import java.time.Instant + import kamon.testkit.{MetricInspection, Reconfigure, TestSpanReporter} import kamon.util.Registration import kamon.Kamon @@ -31,17 +33,17 @@ class LocalSpanSpec extends WordSpec with Matchers with BeforeAndAfterAll with E "be sent to the Span reporters" in { Kamon.buildSpan("test-span") .withTag("test", "value") - .withStartTimestamp(100) + .withFrom(Instant.EPOCH.plusSeconds(1)) .disableMetrics() .enableMetrics() .start() - .finish(200) + .finish(Instant.EPOCH.plusSeconds(10)) eventually(timeout(2 seconds)) { val finishedSpan = reporter.nextSpan().value finishedSpan.operationName shouldBe("test-span") - finishedSpan.startTimestampMicros shouldBe 100 - finishedSpan.endTimestampMicros shouldBe 200 + finishedSpan.from shouldBe Instant.EPOCH.plusSeconds(1) + finishedSpan.to shouldBe Instant.EPOCH.plusSeconds(10) finishedSpan.tags should contain("test" -> TagValue.String("value")) } } @@ -52,22 +54,22 @@ class LocalSpanSpec extends WordSpec with Matchers with BeforeAndAfterAll with E .withTag("builder-boolean-tag-true", true) .withTag("builder-boolean-tag-false", false) .withTag("builder-number-tag", 42) - .withStartTimestamp(100) + .withFrom(Instant.EPOCH.plusSeconds(1)) .start() .tag("span-string-tag", "value") .tag("span-boolean-tag-true", true) .tag("span-boolean-tag-false", false) .tag("span-number-tag", 42) .mark("my-mark") - .mark(100, "my-custom-timetamp-mark") + .mark(Instant.EPOCH.plusSeconds(4), "my-custom-timetamp-mark") .setOperationName("fully-populated-span") - .finish(200) + .finish(Instant.EPOCH.plusSeconds(10)) eventually(timeout(2 seconds)) { val finishedSpan = reporter.nextSpan().value finishedSpan.operationName shouldBe ("fully-populated-span") - finishedSpan.startTimestampMicros shouldBe 100 - finishedSpan.endTimestampMicros shouldBe 200 + finishedSpan.from shouldBe Instant.EPOCH.plusSeconds(1) + finishedSpan.to shouldBe Instant.EPOCH.plusSeconds(10) finishedSpan.tags should contain allOf( "builder-string-tag" -> TagValue.String("value"), "builder-boolean-tag-true" -> TagValue.True, @@ -82,7 +84,7 @@ class LocalSpanSpec extends WordSpec with Matchers with BeforeAndAfterAll with E "my-mark", "my-custom-timetamp-mark" ) - finishedSpan.marks.find(_.key == "my-custom-timetamp-mark").value.timestampMicros should be(100) + finishedSpan.marks.find(_.key == "my-custom-timetamp-mark").value.instant should be(Instant.EPOCH.plusSeconds(4)) } } diff --git a/kamon-core-tests/src/test/scala/kamon/trace/TracerSpec.scala b/kamon-core-tests/src/test/scala/kamon/trace/TracerSpec.scala index eec5b428..a9a4ec10 100644 --- a/kamon-core-tests/src/test/scala/kamon/trace/TracerSpec.scala +++ b/kamon-core-tests/src/test/scala/kamon/trace/TracerSpec.scala @@ -15,6 +15,8 @@ package kamon.trace +import java.time.Instant + import com.typesafe.config.ConfigFactory import kamon.Kamon import kamon.context.Context @@ -85,9 +87,9 @@ class TracerSpec extends WordSpec with Matchers with SpanBuilding with SpanInspe } "allow overriding the start timestamp for a Span" in { - val span = tracer.buildSpan("myOperation").withStartTimestamp(100).start() + val span = tracer.buildSpan("myOperation").withFrom(Instant.EPOCH.plusMillis(321)).start() val spanData = inspect(span) - spanData.startTimestamp() shouldBe 100 + spanData.from() shouldBe Instant.EPOCH.plusMillis(321) } "preserve the same Span and Parent identifier when creating a Span with a remote parent if join-remote-parents-with-same-span-id is enabled" in { -- cgit v1.2.3