aboutsummaryrefslogtreecommitdiff
path: root/kamon-core-tests
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2017-12-13 23:32:30 +0100
committerIvan Topolnjak <ivantopo@gmail.com>2017-12-14 00:05:55 +0100
commit622c8d12735c1a8de3716984686e52bc33368004 (patch)
tree6665d553b6fbea36391e7eb4b25f2fbfc4526f58 /kamon-core-tests
parent4a2d29852c8fc558ae1eaf61a25bde5a0bc161bc (diff)
downloadKamon-622c8d12735c1a8de3716984686e52bc33368004.tar.gz
Kamon-622c8d12735c1a8de3716984686e52bc33368004.tar.bz2
Kamon-622c8d12735c1a8de3716984686e52bc33368004.zip
use java.time.Instant with nanoseconds precision in the Tracer
Diffstat (limited to 'kamon-core-tests')
-rw-r--r--kamon-core-tests/src/test/scala/kamon/trace/LocalSpanSpec.scala22
-rw-r--r--kamon-core-tests/src/test/scala/kamon/trace/TracerSpec.scala6
2 files changed, 16 insertions, 12 deletions
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 {