Skip to content

Commit

Permalink
Merge pull request #10 from sjoerdmulder/bugfix/9
Browse files Browse the repository at this point in the history
Fix for issue #9
  • Loading branch information
ivantopo committed Jun 16, 2019
2 parents f649278 + 4f226bb commit 1b7c20b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: scala
script:
- sbt publishLocal
- sbt test publishLocal
scala:
- 2.12.6
- 2.12.8
jdk:
- oraclejdk8
before_script:
Expand Down
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
scalaVersion := "2.12.6"
scalaVersion := "2.12.8"
resolvers += Resolver.mavenLocal
resolvers += Resolver.bintrayRepo("kamon-io", "snapshots")

libraryDependencies += "io.kamon" %% "kamon-core" % "1.1.3"
libraryDependencies += "io.zipkin.reporter2" % "zipkin-reporter" % "2.7.7"
libraryDependencies += "io.zipkin.reporter2" % "zipkin-sender-okhttp3" % "2.7.7"
libraryDependencies += "io.kamon" %% "kamon-core" % "1.1.5"
libraryDependencies += "io.zipkin.reporter2" % "zipkin-reporter" % "2.7.14"
libraryDependencies += "io.zipkin.reporter2" % "zipkin-sender-okhttp3" % "2.7.14"
libraryDependencies += scalatest % "test"
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.17
sbt.version=1.2.6
3 changes: 1 addition & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
lazy val root: Project = project.in(file(".")).dependsOn(latestSbtUmbrella)
lazy val latestSbtUmbrella = uri("git://github.com/kamon-io/kamon-sbt-umbrella.git")
lazy val root: Project = project in file(".") dependsOn(RootProject(uri("git://github.com/kamon-io/kamon-sbt-umbrella.git")))
5 changes: 4 additions & 1 deletion src/main/scala/kamon/zipkin/Zipkin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package kamon.zipkin
import java.net.InetAddress

import com.typesafe.config.Config
import kamon.trace.IdentityProvider
import kamon.{Kamon, SpanReporter}
import kamon.trace.Span.{Mark, TagValue, FinishedSpan => KamonSpan}
import kamon.util.Clock
Expand Down Expand Up @@ -51,11 +52,13 @@ class ZipkinReporter extends SpanReporter {
private[zipkin] def convertSpan(kamonSpan: KamonSpan): ZipkinSpan = {
val context = kamonSpan.context
val duration = Math.floorDiv(Clock.nanosBetween(kamonSpan.from, kamonSpan.to), 1000)
// Zipkin uses null to identify no identifier
val parentId: String = if (context.parentID.equals(IdentityProvider.NoIdentifier)) null else context.parentID.string
val builder = ZipkinSpan.newBuilder()
.localEndpoint(localEndpoint)
.traceId(context.traceID.string)
.id(context.spanID.string)
.parentId(context.parentID.string)
.parentId(parentId)
.name(kamonSpan.operationName)
.timestamp(Clock.toEpochMicros(kamonSpan.from))
.duration(duration)
Expand Down
13 changes: 12 additions & 1 deletion src/test/scala/kamon/zipkin/SpanConversionSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.time.Instant

import kamon.trace.IdentityProvider.Identifier
import kamon.trace.SpanContext.SamplingDecision
import kamon.trace.{Span, SpanContext}
import kamon.trace.{IdentityProvider, Span, SpanContext}
import kamon.util.Clock
import zipkin2.{Endpoint, Span => ZipkinSpan}
import org.scalatest.{Matchers, WordSpec}
Expand All @@ -23,6 +23,17 @@ class SpanConversionSpec extends WordSpec with Matchers {
zipkinSpan.timestamp() shouldBe Clock.toEpochMicros(kamonSpan.from)
}

"convert span without parent" in {
val kamonSpan = newSpan().build()
val zipkinSpan = convert(kamonSpan.copy(context =
kamonSpan.context.copy(parentID = IdentityProvider.NoIdentifier)
))

zipkinSpan.traceId() shouldBe kamonSpan.context.traceID.string
zipkinSpan.id() shouldBe kamonSpan.context.spanID.string
zipkinSpan.parentId() shouldBe null
}

"assign a Span kind for client and server operations" in {
val noKindSpan = newSpan().build()

Expand Down

0 comments on commit 1b7c20b

Please sign in to comment.