Skip to content

Commit 35b4cda

Browse files
authored
Dependency Updates (#53)
* Dependency updates * Update microsite
1 parent eb18ee6 commit 35b4cda

File tree

17 files changed

+103
-52
lines changed

17 files changed

+103
-52
lines changed

build.sbt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import microsites.MicrositesPlugin.autoImport.micrositeDescription
22

3-
scalaVersion in ThisBuild := "2.13.1"
3+
scalaVersion in ThisBuild := "2.13.4"
44

55
classLoaderLayeringStrategy in ThisBuild := ClassLoaderLayeringStrategy.ScalaLibrary
66

@@ -18,12 +18,12 @@ val common = Seq(
1818
git.useGitDescribe := true,
1919
libraryDependencies ++= Seq(
2020
compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"),
21-
compilerPlugin("org.typelevel" % "kind-projector" % "0.11.0" cross CrossVersion.full),
22-
"org.typelevel" %% "cats-core" % "2.1.1",
23-
"org.typelevel" %% "cats-effect" % "2.1.2",
24-
"org.scalatest" %% "scalatest" % "3.1.1" % Test,
25-
"org.scalacheck" %% "scalacheck" % "1.14.3" % Test,
26-
"org.scalatestplus" %% "scalacheck-1-14" % "3.1.1.1" % Test
21+
compilerPlugin("org.typelevel" % "kind-projector" % "0.11.3" cross CrossVersion.full),
22+
"org.typelevel" %% "cats-core" % "2.3.1",
23+
"org.typelevel" %% "cats-effect" % "2.3.1",
24+
"org.scalatest" %% "scalatest" % "3.2.3" % Test,
25+
"org.scalacheck" %% "scalacheck" % "1.15.2" % Test,
26+
"org.scalatestplus" %% "scalacheck-1-14" % "3.2.2.0" % Test
2727
),
2828
)
2929

@@ -32,12 +32,12 @@ lazy val metricsCommon = project
3232
.enablePlugins(GitVersioning)
3333
.settings(common :+ (name := "metrics-common"))
3434

35-
val log4catsVersion = "1.0.1"
36-
val natchezVersion = "0.0.11"
37-
val http4sVersion = "0.21.2"
35+
val log4catsVersion = "1.1.1"
36+
val natchezVersion = "0.0.19"
37+
val http4sVersion = "0.21.16"
3838
val circeVersion = "0.13.0"
3939
val slf4jVersion = "1.7.30"
40-
val fs2Version = "2.3.0"
40+
val fs2Version = "2.5.0"
4141

4242
lazy val natchezDatadog = project
4343
.in(file("natchez-datadog"))
@@ -110,14 +110,14 @@ lazy val natchezFs2 = project
110110
.settings(common :+ (name := "natchez-fs2"))
111111
.settings(
112112
libraryDependencies ++= Seq(
113-
"org.typelevel" %% "kittens" % "2.0.0",
113+
"org.typelevel" %% "kittens" % "2.2.1",
114114
"org.tpolecat" %% "natchez-core" % natchezVersion,
115115
"co.fs2" %% "fs2-core" % fs2Version
116116
)
117117
)
118118

119-
val silencerVersion = "1.6.0"
120-
val doobieVersion = "0.8.8"
119+
val silencerVersion = "1.7.1"
120+
val doobieVersion = "0.10.0"
121121
lazy val natchezDoobie = project
122122
.in(file("natchez-doobie"))
123123
.enablePlugins(GitVersioning)

docs/docs/docs/natchez-fs2.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ If the stream is cancelled the span will be closed automatically.
3434
```scala mdoc
3535
import cats.Monad
3636
import cats.effect.{ExitCode, IO, IOApp}
37-
import cats.syntax.functor._
3837
import com.ovoenergy.effect.natchez.syntax._
3938
import com.ovoenergy.effect.natchez.{AllocatedSpan, Slf4j}
4039
import fs2._

docs/docs/docs/natchez-http4s.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ object NatchezHttp4s extends IOApp {
9494
/**
9595
* We can then serve the routes as normal
9696
*/
97-
BlazeServerBuilder[IO]
97+
BlazeServerBuilder[IO](global)
9898
.bindHttp(8080, "0.0.0.0")
9999
.withHttpApp(routes)
100100
.withoutBanner

natchez-combine/src/main/scala/com/ovoenergy/effect/natchez/Combine.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.ovoenergy.effect.natchez
22

3+
import cats.data.OptionT
34
import cats.effect.{Resource, Sync}
45
import cats.syntax.apply._
56
import cats.syntax.functor._
67
import natchez.{EntryPoint, Kernel, Span, TraceValue}
78

9+
import java.net.URI
10+
811
/**
912
* Given to separate tracing integrations combine them by calling each one of them
1013
* for all natchez operations. When producing kernels we merge the kernels for maximum compatibility
@@ -19,6 +22,12 @@ object Combine {
1922
(s1.span(name), s2.span(name)).mapN[Span[F]](combineSpan[F])
2023
def put(fields: (String, TraceValue)*): F[Unit] =
2124
(s1.put(fields: _*), s2.put(fields: _*)).tupled.as(())
25+
def traceId: F[Option[String]] =
26+
OptionT(s1.traceId).orElseF(s2.traceId).value
27+
def spanId: F[Option[String]] =
28+
OptionT(s1.spanId).orElseF(s2.spanId).value
29+
def traceUri: F[Option[URI]] =
30+
OptionT(s1.traceUri).orElseF(s2.traceUri).value
2231
}
2332

2433
def combine[F[_]: Sync](e1: EntryPoint[F], e2: EntryPoint[F]): EntryPoint[F] =

natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/DatadogSpan.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import cats.syntax.traverse._
1212
import cats.instances.option._
1313
import natchez.TraceValue.{BooleanValue, NumberValue, StringValue}
1414

15+
import java.net.URI
1516
import java.util.concurrent.TimeUnit.NANOSECONDS
1617

1718
/**
@@ -43,6 +44,15 @@ case class DatadogSpan[F[_]: Sync: Clock](
4344

4445
def kernel: F[Kernel] =
4546
ids.get.map(SpanIdentifiers.toKernel)
47+
48+
def traceId: F[Option[String]] =
49+
ids.get.map(id => Some(id.traceId.toString))
50+
51+
def spanId: F[Option[String]] =
52+
ids.get.map(id => Some(id.spanId.toString))
53+
54+
def traceUri: F[Option[URI]] =
55+
Sync[F].pure(None)
4656
}
4757

4858
object DatadogSpan {

natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/SpanIdentifiers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ case class SpanIdentifiers(
2020
object SpanIdentifiers {
2121

2222
private def randomAbsLong[F[_]: Sync]: F[Long] =
23-
Sync[F].delay(scala.util.Random.nextLong.abs)
23+
Sync[F].delay(scala.util.Random.nextLong().abs)
2424

2525
private def randomUUID[F[_]: Sync]: F[String] =
2626
Sync[F].delay(UUID.randomUUID.toString)

natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez/DatadogTest.scala

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import com.ovoenergy.effect.natchez.Datadog.entryPoint
88
import com.ovoenergy.effect.natchez.DatadogTags.SpanType.{Cache, Db, Web}
99
import com.ovoenergy.effect.natchez.DatadogTags.spanType
1010
import natchez.EntryPoint
11-
import natchez.TraceValue.StringValue
1211
import org.http4s.Request
1312
import org.http4s.circe.CirceEntityDecoder._
1413
import org.http4s.syntax.literals._
@@ -78,8 +77,8 @@ class DatadogTest extends AnyWordSpec with Matchers {
7877

7978
"Submit the right info to Datadog when closed" in {
8079

81-
val res = run(_.root("bar:res").use(_.put("k" -> StringValue("v")) >> IO.sleep(1.milli))).unsafeRunSync
82-
val span = res.flatTraverse(_.as[List[List[SubmittableSpan]]]).unsafeRunSync.flatten.head
80+
val res = run(_.root("bar:res").use(_.put("k" -> "v") >> IO.sleep(1.milli))).unsafeRunSync()
81+
val span = res.flatTraverse(_.as[List[List[SubmittableSpan]]]).unsafeRunSync().flatten.head
8382

8483
span.name shouldBe "bar"
8584
span.service shouldBe "test"
@@ -93,22 +92,22 @@ class DatadogTest extends AnyWordSpec with Matchers {
9392

9493
"Infer the right span.type from any tags set" in {
9594
Inspectors.forAll(List(Web, Cache, Db)) { typ =>
96-
val res = run(_.root("bar:res").use(_.put(spanType(typ)))).unsafeRunSync
97-
val span = res.flatTraverse(_.as[List[List[SubmittableSpan]]]).unsafeRunSync.flatten.head
95+
val res = run(_.root("bar:res").use(_.put(spanType(typ)))).unsafeRunSync()
96+
val span = res.flatTraverse(_.as[List[List[SubmittableSpan]]]).unsafeRunSync().flatten.head
9897
span.`type` shouldBe Some(typ)
9998
}
10099
}
101100

102101
"Submit multiple spans across multiple calls when span() is called" in {
103-
val res = run(_.root("bar").use(_.span("subspan").use(_ => timer.sleep(1.second)))).unsafeRunSync
104-
val spans = res.flatTraverse(_.as[List[List[SubmittableSpan]]]).unsafeRunSync.flatten
102+
val res = run(_.root("bar").use(_.span("subspan").use(_ => timer.sleep(1.second)))).unsafeRunSync()
103+
val spans = res.flatTraverse(_.as[List[List[SubmittableSpan]]]).unsafeRunSync().flatten
105104
spans.map(_.traceId).distinct.length shouldBe 1
106105
spans.map(_.spanId).distinct.length shouldBe 2
107106
}
108107

109108
"Allow you to override the service name and resource with colons" in {
110-
val res = run(_.root("svc:name:res").use(_ => IO.unit)).unsafeRunSync
111-
val spans = res.flatTraverse(_.as[List[List[SubmittableSpan]]]).unsafeRunSync.flatten
109+
val res = run(_.root("svc:name:res").use(_ => IO.unit)).unsafeRunSync()
110+
val spans = res.flatTraverse(_.as[List[List[SubmittableSpan]]]).unsafeRunSync().flatten
112111
spans.head.resource shouldBe "res"
113112
spans.head.service shouldBe "svc"
114113
spans.head.name shouldBe "name"
@@ -119,9 +118,9 @@ class DatadogTest extends AnyWordSpec with Matchers {
119118
_.root("bar:res").use { root =>
120119
root.put("foo" -> "bar") >> root.span("sub").use(_.put("baz" -> "qux"))
121120
}
122-
).unsafeRunSync
121+
).unsafeRunSync()
123122

124-
val spans = res.flatTraverse(_.as[List[List[SubmittableSpan]]]).unsafeRunSync.flatten
123+
val spans = res.flatTraverse(_.as[List[List[SubmittableSpan]]]).unsafeRunSync().flatten
125124
val rootSpan = spans.find(_.name == "bar").get
126125
val subSpan = spans.find(_.name == "sub").get
127126

natchez-datadog/src/test/scala/com/ovoenergy/effect/natchez/SpanIdentifiersTest.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SpanIdentifiersTest extends AnyWordSpec with Matchers with Checkers {
1818
parent <- SpanIdentifiers.create[IO]
1919
child <- SpanIdentifiers.child[IO](parent)
2020
} yield parent -> child
21-
).unsafeRunSync
21+
).unsafeRunSync()
2222

2323
parent.parentId shouldBe None
2424
child.traceId shouldBe parent.traceId
@@ -32,7 +32,7 @@ class SpanIdentifiersTest extends AnyWordSpec with Matchers with Checkers {
3232
ids <- create[IO]
3333
kernel <- fromKernel[IO](SpanIdentifiers.toKernel(ids))
3434
} yield ids -> kernel
35-
).unsafeRunSync
35+
).unsafeRunSync()
3636

3737
kernel.traceId shouldBe original.traceId
3838
kernel.traceToken shouldBe original.traceToken
@@ -41,11 +41,11 @@ class SpanIdentifiersTest extends AnyWordSpec with Matchers with Checkers {
4141
}
4242

4343
"Succeed in converting from a kernel even if info is missing" in {
44-
fromKernel[IO](Kernel(Map.empty)).attempt.unsafeRunSync should matchPattern { case Right(_) => }
45-
fromKernel[IO](Kernel(Map("X-Trace-Token" -> "foo"))).unsafeRunSync.traceToken shouldBe "foo"
44+
fromKernel[IO](Kernel(Map.empty)).attempt.unsafeRunSync() should matchPattern { case Right(_) => }
45+
fromKernel[IO](Kernel(Map("X-Trace-Token" -> "foo"))).unsafeRunSync().traceToken shouldBe "foo"
4646
}
4747

4848
"Ignore header case when extracting info" in {
49-
fromKernel[IO](Kernel(Map("x-TRACe-tokeN" -> "foo"))).unsafeRunSync.traceToken shouldBe "foo"
49+
fromKernel[IO](Kernel(Map("x-TRACe-tokeN" -> "foo"))).unsafeRunSync().traceToken shouldBe "foo"
5050
}
5151
}

natchez-doobie/src/test/scala/com/ovoenergy/effect/natchez/TracedTransactorTest.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.ovoenergy.effect.natchez
22

33
import cats.effect.concurrent.Ref
44
import cats.effect.{Blocker, ContextShift, IO, Resource}
5-
import cats.syntax.functor._
65
import com.ovoenergy.effect.natchez.TracedTransactor.Traced
76
import doobie.h2.H2Transactor.newH2Transactor
87
import doobie.implicits._
@@ -12,6 +11,7 @@ import org.scalatest.matchers.should.Matchers
1211
import org.scalatest.wordspec.AnyWordSpec
1312
import cats.syntax.flatMap._
1413

14+
import java.net.URI
1515
import scala.concurrent.ExecutionContext.global
1616

1717
class TracedTransactorTest extends AnyWordSpec with Matchers {
@@ -31,6 +31,12 @@ class TracedTransactorTest extends AnyWordSpec with Matchers {
3131
IO.pure(Kernel(Map.empty))
3232
def put(fields: (String, TraceValue)*): IO[Unit] =
3333
sps.update(s => s.dropRight(1) :+ s.last.copy(tags = s.last.tags ++ fields.toMap))
34+
def traceId: IO[Option[String]] =
35+
IO.pure(None)
36+
def spanId: IO[Option[String]] =
37+
IO.pure(None)
38+
def traceUri: IO[Option[URI]] =
39+
IO.pure(None)
3440
}
3541
a.run(spanMock).attempt.flatMap(_ => sps.get)
3642
}

natchez-fs2/src/main/scala/com/ovoenergy/effect/natchez/AllocatedSpan.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import fs2.concurrent.Queue
88
import fs2.{Pipe, Stream}
99
import natchez.{Kernel, Span, TraceValue}
1010

11+
import java.net.URI
12+
1113
/**
1214
* A Natchez span that has been pre-allocated and will stay open
1315
* until either the stream that created it terminates or you call submit
@@ -48,6 +50,12 @@ object AllocatedSpan {
4850
createSpan(spn, F.uncancelable(F.attempt(task) >> submit))
4951
def submit: F[Unit] =
5052
submitTask
53+
def traceId: F[Option[String]] =
54+
spn.traceId
55+
def spanId: F[Option[String]] =
56+
spn.spanId
57+
def traceUri: F[Option[URI]] =
58+
spn.traceUri
5159
}
5260

5361
/**
@@ -60,7 +68,7 @@ object AllocatedSpan {
6068

6169
object Traced {
6270
implicit def traverse[F[_]]: Traverse[Traced[F, *]] =
63-
cats.derived.semi.traverse[Traced[F, *]]
71+
cats.derived.semiauto.traverse[Traced[F, *]]
6472
}
6573

6674
/**

0 commit comments

Comments
 (0)