From 70a06416d219fe7064cfd07f9019555d57eb008a Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 13 Dec 2020 15:25:10 -0600 Subject: [PATCH 001/178] ce3 --- .github/workflows/build.yml | 2 +- build.sbt | 126 +++++++++--------- .../core/shared/src/main/scala/Trace.scala | 6 +- .../examples/src/main/scala-2/Example.scala | 6 +- .../src/main/scala-2/NewrelicExample.scala | 61 --------- .../src/main/scala/HoneycombSpan.scala | 16 +-- .../natchez/newrelic/NewrelicSpan.scala | 2 +- .../src/main/scala/OpenCensusSpan.scala | 14 +- project/plugins.sbt | 21 +-- 9 files changed, 100 insertions(+), 154 deletions(-) delete mode 100644 modules/examples/src/main/scala-2/NewrelicExample.scala diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2cbf90ff..2236a2b6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,4 +17,4 @@ jobs: ~/.sbt key: sbt-${{ hashFiles('**/build.sbt') }} - name: Run tests - run: csbt headerCheck +clean +test + run: csbt headerCheck +clean evictionCheck +test diff --git a/build.sbt b/build.sbt index fc356a7c..9525ad16 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,22 @@ val scala30PreviousVersion = "3.0.0-M1" val scala30Version = "3.0.0-M2" val catsVersion = "2.3.0" -val catsEffectVersion = "2.3.0" +val catsEffectVersion = "3.0.0-M4" + +// We do `evictionCheck` in CI and don't sweat the Java deps for now. +inThisBuild(Seq( + evictionRules ++= Seq( + "io.netty" % "*" % "always", + "io.grpc" % "*" % "always", + "com.github.jnr" % "*" % "always", + "com.google.guava" % "*" % "always", + "io.opentracing" % "*" % "always", + "io.opentracing.contrib" % "*" % "always", + "com.squareup.okhttp3" % "*" % "always", + "com.squareup.okio" % "*" % "always", + "org.typelevel" % "*" % "semver-spec", + ) +)) // Global Settings lazy val commonSettings = Seq( @@ -79,16 +94,8 @@ lazy val commonSettings = Seq( ) -lazy val natchez = project - .in(file(".")) - .enablePlugins(AutomateHeaderPlugin) - .settings(commonSettings) - .settings( - crossScalaVersions := Nil, - publish / skip := true - ) - .dependsOn(coreJS, coreJVM, jaeger, honeycomb, opencensus, datadog, lightstep, lightstepGrpc, lightstepHttp, logJS, logJVM, noop, mock, newrelic, examples) - .aggregate(coreJS, coreJVM, jaeger, honeycomb, opencensus, datadog, lightstep, lightstepGrpc, lightstepHttp, logJS, logJVM, noop, mock, newrelic, examples) +// root project +publish / skip := true lazy val core = crossProject(JSPlatform, JVMPlatform) .in(file("modules/core")) @@ -99,6 +106,7 @@ lazy val core = crossProject(JSPlatform, JVMPlatform) description := "Tagless, non-blocking OpenTracing implementation for Scala.", libraryDependencies ++= Seq( "org.typelevel" %%% "cats-core" % catsVersion, + "org.typelevel" %%% "cats-effect-kernel" % catsEffectVersion, "org.typelevel" %%% "cats-effect" % catsEffectVersion, ) ) @@ -122,7 +130,7 @@ lazy val jaeger = project description := "Jaeger support for Natchez.", libraryDependencies ++= Seq( ("org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6").withDottyCompat(scalaVersion.value), - "io.jaegertracing" % "jaeger-client" % "1.4.0", + "io.jaegertracing" % "jaeger-client" % "1.5.0", ) ) @@ -136,7 +144,7 @@ lazy val honeycomb = project description := "Honeycomb support for Natchez.", libraryDependencies ++= Seq( ("org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6").withDottyCompat(scalaVersion.value), - "io.honeycomb.libhoney" % "libhoney-java" % "1.2.0" + "io.honeycomb.libhoney" % "libhoney-java" % "1.3.1" ) ) @@ -149,7 +157,7 @@ lazy val opencensus = project name := "natchez-opencensus", description := "Opencensus support for Natchez.", libraryDependencies ++= Seq( - "io.opencensus" % "opencensus-exporter-trace-ocagent" % "0.27.1" + "io.opencensus" % "opencensus-exporter-trace-ocagent" % "0.28.2" ) ) @@ -163,7 +171,7 @@ lazy val lightstep = project description := "Lightstep support for Natchez.", libraryDependencies ++= Seq( ("org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6").withDottyCompat(scalaVersion.value), - "com.lightstep.tracer" % "lightstep-tracer-jre" % "0.30.2" + "com.lightstep.tracer" % "lightstep-tracer-jre" % "0.30.3" ) ) @@ -177,8 +185,8 @@ lazy val lightstepGrpc = project description := "Lightstep gRPC bindings for Natchez.", libraryDependencies ++= Seq( "com.lightstep.tracer" % "tracer-grpc" % "0.30.1", - "io.grpc" % "grpc-netty" % "1.31.1", - "io.netty" % "netty-tcnative-boringssl-static" % "2.0.34.Final" + "io.grpc" % "grpc-netty" % "1.34.0", + "io.netty" % "netty-tcnative-boringssl-static" % "2.0.35.Final" ) ) @@ -205,33 +213,33 @@ lazy val datadog = project description := "Lightstep HTTP bindings for Natchez.", libraryDependencies ++= Seq( ("org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6").withDottyCompat(scalaVersion.value), - "com.datadoghq" % "dd-trace-ot" % "0.61.0", - "com.datadoghq" % "dd-trace-api" % "0.61.0" + "com.datadoghq" % "dd-trace-ot" % "0.69.0", + "com.datadoghq" % "dd-trace-api" % "0.69.0" ) ) -lazy val log = crossProject(JSPlatform, JVMPlatform) - .in(file("modules/log")) - .dependsOn(core) - .enablePlugins(AutomateHeaderPlugin) - .settings(commonSettings) - .settings( - publish / skip := isDotty.value, - name := "natchez-log", - description := "Logging bindings for Natchez.", - libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.13.0", - "io.chrisdavenport" %% "log4cats-core" % "1.1.1", - ).filterNot(_ => isDotty.value) - ) -lazy val logJVM = log.jvm -lazy val logJS = log.js - .settings( - scalaJSStage in Test := FastOptStage, - jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(), - scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), - crossScalaVersions := crossScalaVersions.value.filterNot(_ == "3.0.0-M1"), - ) +// lazy val log = crossProject(JSPlatform, JVMPlatform) +// .in(file("modules/log")) +// .dependsOn(core) +// .enablePlugins(AutomateHeaderPlugin) +// .settings(commonSettings) +// .settings( +// publish / skip := isDotty.value, +// name := "natchez-log", +// description := "Logging bindings for Natchez.", +// libraryDependencies ++= Seq( +// "io.circe" %% "circe-core" % "0.13.0", +// "io.chrisdavenport" %% "log4cats-core" % "1.1.1", +// ).filterNot(_ => isDotty.value) +// ) +// lazy val logJVM = log.jvm +// lazy val logJS = log.js +// .settings( +// scalaJSStage in Test := FastOptStage, +// jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(), +// scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), +// crossScalaVersions := crossScalaVersions.value.filterNot(_ == "3.0.0-M1"), +// ) lazy val newrelic = project .in(file("modules/newrelic")) @@ -245,9 +253,9 @@ lazy val newrelic = project libraryDependencies ++= Seq( "io.circe" %% "circe-core" % "0.13.0", ("org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6").withDottyCompat(scalaVersion.value), - "com.newrelic.telemetry" % "telemetry" % "0.4.0", - "com.newrelic.telemetry" % "telemetry-core" % "0.4.0", - "com.newrelic.telemetry" % "telemetry-http-okhttp" % "0.4.0" + "com.newrelic.telemetry" % "telemetry" % "0.9.0", + "com.newrelic.telemetry" % "telemetry-core" % "0.9.0", + "com.newrelic.telemetry" % "telemetry-http-okhttp" % "0.9.0" ).filterNot(_ => isDotty.value) ) @@ -276,19 +284,17 @@ lazy val mock = project )) -lazy val examples = project - .in(file("modules/examples")) - .dependsOn(coreJVM, jaeger, honeycomb, lightstepHttp, datadog, logJVM, newrelic) - .enablePlugins(AutomateHeaderPlugin) - .settings(commonSettings) - .settings( - publish / skip := true, - name := "natchez-examples", - description := "Example programs for Natchez.", - libraryDependencies ++= Seq( - "io.chrisdavenport" %% "log4cats-slf4j" % "1.1.1", - "org.slf4j" % "slf4j-simple" % "1.7.30", - "eu.timepit" %% "refined" % "0.9.18", - "is.cir" %% "ciris" % "1.2.1" - ).filterNot(_ => isDotty.value) - ) +// lazy val examples = project +// .in(file("modules/examples")) +// .dependsOn(coreJVM, jaeger, honeycomb, lightstepHttp, datadog, logJVM, newrelic) +// .enablePlugins(AutomateHeaderPlugin) +// .settings(commonSettings) +// .settings( +// publish / skip := true, +// name := "natchez-examples", +// description := "Example programs for Natchez.", +// libraryDependencies ++= Seq( +// "io.chrisdavenport" %% "log4cats-slf4j" % "1.1.1", +// "org.slf4j" % "slf4j-simple" % "1.7.30", +// ).filterNot(_ => isDotty.value) +// ) diff --git a/modules/core/shared/src/main/scala/Trace.scala b/modules/core/shared/src/main/scala/Trace.scala index 8c465f19..524a6c69 100644 --- a/modules/core/shared/src/main/scala/Trace.scala +++ b/modules/core/shared/src/main/scala/Trace.scala @@ -63,10 +63,10 @@ object Trace { } /** - * `Kleisli[F, Span[F], *]` is a `Trace` given `Bracket[F, Throwable]`. The instance can be + * `Kleisli[F, Span[F], *]` is a `Trace` given `MonadCancel[F, Throwable]`. The instance can be * widened to an environment that *contains* a `Span[F]` via the `lens` method. */ - implicit def kleisliInstance[F[_]](implicit ev: Bracket[F, Throwable]): KleisliTrace[F] = + implicit def kleisliInstance[F[_]](implicit ev: MonadCancel[F, Throwable]): KleisliTrace[F] = new KleisliTrace[F] /** @@ -74,7 +74,7 @@ object Trace { * context into our computations. We can also "lensMap" out to `Kleisli[F, E, *]` given a lens * from `E` to `Span[F]`. */ - class KleisliTrace[F[_]](implicit ev: Bracket[F, Throwable]) extends Trace[Kleisli[F, Span[F], *]] { + class KleisliTrace[F[_]](implicit ev: MonadCancel[F, Throwable]) extends Trace[Kleisli[F, Span[F], *]] { def kernel: Kleisli[F, Span[F], Kernel] = Kleisli(_.kernel) diff --git a/modules/examples/src/main/scala-2/Example.scala b/modules/examples/src/main/scala-2/Example.scala index 2b9f5358..6029e8cb 100644 --- a/modules/examples/src/main/scala-2/Example.scala +++ b/modules/examples/src/main/scala-2/Example.scala @@ -17,9 +17,9 @@ object Main extends IOApp { // Intentionally slow parallel quicksort, to demonstrate branching. If we run too quickly it seems // to break Jaeger with "skipping clock skew adjustment" so let's pause a bit each time. - def qsort[F[_]: Monad: Parallel: Trace: Timer, A: Order](as: List[A]): F[List[A]] = + def qsort[F[_]: Parallel: Trace: Temporal, A: Order](as: List[A]): F[List[A]] = Trace[F].span(as.mkString(",")) { - Timer[F].sleep(10.milli) *> { + Temporal[F].sleep(10.milli) *> { as match { case Nil => Monad[F].pure(Nil) case h :: t => @@ -29,7 +29,7 @@ object Main extends IOApp { } } - def runF[F[_]: Sync: Trace: Parallel: Timer]: F[Unit] = + def runF[F[_]: Async: Trace: Parallel]: F[Unit] = Trace[F].span("Sort some stuff!") { for { as <- Sync[F].delay(List.fill(100)(Random.nextInt(1000))) diff --git a/modules/examples/src/main/scala-2/NewrelicExample.scala b/modules/examples/src/main/scala-2/NewrelicExample.scala deleted file mode 100644 index abc08115..00000000 --- a/modules/examples/src/main/scala-2/NewrelicExample.scala +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2019-2020 by Rob Norris and Contributors -// This software is licensed under the MIT License (MIT). -// For more information see LICENSE or https://opensource.org/licenses/MIT - -import cats._ -import cats.data.Kleisli -import cats.effect._ -import cats.implicits._ -import com.newrelic.telemetry.SimpleSpanBatchSender -import natchez._ -import natchez.newrelic.NewRelic - -import scala.util.Random -import scala.concurrent.duration._ - -object NewrelicExample extends IOApp { - - // Intentionally slow parallel quicksort, to demonstrate branching. If we run too quickly it seems - // to break Jaeger with "skipping clock skew adjustment" so let's pause a bit each time. - def qsort[F[_]: Monad: Parallel: Trace: Timer, A: Order](as: List[A]): F[List[A]] = - Trace[F].span(as.mkString(",")) { - Timer[F].sleep(10.milli) *> { - as match { - case Nil => Monad[F].pure(Nil) - case h :: t => - val (a, b) = t.partition(_ <= h) - (qsort[F, A](a), qsort[F, A](b)).parMapN(_ ++ List(h) ++ _) - } - } - } - - def runF[F[_]: Sync: Trace: Parallel: Timer]: F[Unit] = - Trace[F].span("Sort some stuff!") { - for { - as <- Sync[F].delay(List.fill(100)(Random.nextInt(1000))) - _ <- qsort[F, Int](as) - } yield () - } - - // Jaeger - def entryPoint[F[_]: Sync](apiKey: String): EntryPoint[F] = - NewRelic.entryPoint[F]("qsort_example") { - - SimpleSpanBatchSender - .builder(apiKey, java.time.Duration.ofSeconds(5)) - .enableAuditLogging() - .build() - } - - def run(args: List[String]): IO[ExitCode] = - ciris - .env("NR_API_KEY") - .load[IO] - .flatMap( - apiKey => - entryPoint[IO](apiKey) - .root("this is the root span") - .use(span => runF[Kleisli[IO, Span[IO], *]].run(span)) - .as(ExitCode.Success)) - -} diff --git a/modules/honeycomb/src/main/scala/HoneycombSpan.scala b/modules/honeycomb/src/main/scala/HoneycombSpan.scala index 6f53ab1d..69ad459e 100644 --- a/modules/honeycomb/src/main/scala/HoneycombSpan.scala +++ b/modules/honeycomb/src/main/scala/HoneycombSpan.scala @@ -4,10 +4,10 @@ package natchez.honeycomb -import cats.effect.concurrent.Ref import cats.effect._ -import cats.effect.ExitCase.Canceled -import cats.effect.ExitCase.Completed +import cats.effect.Resource.ExitCase +import cats.effect.Resource.ExitCase._ + import cats.syntax.all._ import io.honeycomb.libhoney.HoneyClient import java.time.Instant @@ -59,11 +59,11 @@ private[honeycomb] object HoneycombSpan { private def now[F[_]: Sync]: F[Instant] = Sync[F].delay(Instant.now) - def finish[F[_]: Sync]: (HoneycombSpan[F], ExitCase[Throwable]) => F[Unit] = { (span, exitCase) => + def finish[F[_]: Sync]: (HoneycombSpan[F], ExitCase) => F[Unit] = { (span, exitCase) => for { // collect error details, if any _ <- exitCase.some.collect { - case ExitCase.Error(t: Fields) => t.fields + case Errored(t: Fields) => t.fields } .traverse(m => span.fields.update(_ ++ m)) n <- now fs <- span.fields.get @@ -77,9 +77,9 @@ private[honeycomb] object HoneycombSpan { e.addField("trace.trace_id", span.traceUUID) e.addField("duration_ms", n.toEpochMilli - span.timestamp.toEpochMilli) exitCase match { - case Completed => e.addField("exit.case", "completed") - case Canceled => e.addField("exit.case", "canceled") - case ExitCase.Error(ex) => + case Succeeded => e.addField("exit.case", "completed") + case Canceled => e.addField("exit.case", "canceled") + case Errored(ex) => e.addField("exit.case", "error") e.addField("exit.error.class", ex.getClass.getName) e.addField("exit.error.message", ex.getMessage) diff --git a/modules/newrelic/src/main/scala-2/natchez/newrelic/NewrelicSpan.scala b/modules/newrelic/src/main/scala-2/natchez/newrelic/NewrelicSpan.scala index 1ae6ea7d..48ddbf42 100644 --- a/modules/newrelic/src/main/scala-2/natchez/newrelic/NewrelicSpan.scala +++ b/modules/newrelic/src/main/scala-2/natchez/newrelic/NewrelicSpan.scala @@ -7,7 +7,7 @@ package natchez.newrelic import java.net.URI import java.util.UUID -import cats.effect.concurrent.Ref +import cats.effect.Ref import cats.effect.{Resource, Sync} import cats.implicits._ import com.newrelic.telemetry.Attributes diff --git a/modules/opencensus/src/main/scala/OpenCensusSpan.scala b/modules/opencensus/src/main/scala/OpenCensusSpan.scala index 1932f115..fc637575 100644 --- a/modules/opencensus/src/main/scala/OpenCensusSpan.scala +++ b/modules/opencensus/src/main/scala/OpenCensusSpan.scala @@ -6,8 +6,8 @@ package natchez package opencensus import cats.effect._ -import cats.effect.ExitCase.Canceled -import cats.effect.ExitCase.Completed +import cats.effect.Resource.ExitCase +import cats.effect.Resource.ExitCase._ import cats.syntax.all._ import io.opencensus.trace.propagation.TextFormat.Setter import io.opencensus.trace.{AttributeValue, Sampler, Tracer, Tracing} @@ -69,17 +69,17 @@ private[opencensus] object OpenCensusSpan { } } - def finish[F[_]: Sync]: (OpenCensusSpan[F], ExitCase[Throwable]) => F[Unit] = { (outer, exitCase) => + def finish[F[_]: Sync]: (OpenCensusSpan[F], ExitCase) => F[Unit] = { (outer, exitCase) => for { // collect error details, if any _ <- exitCase.some.collect { - case ExitCase.Error(t: Fields) => t.fields.toList + case Errored(t: Fields) => t.fields.toList }.traverse(outer.put) _ <- Sync[F].delay { exitCase match { - case Completed => outer.span.setStatus(io.opencensus.trace.Status.OK) - case Canceled => outer.span.setStatus(io.opencensus.trace.Status.CANCELLED) - case ExitCase.Error(ex) => + case Succeeded => outer.span.setStatus(io.opencensus.trace.Status.OK) + case Canceled => outer.span.setStatus(io.opencensus.trace.Status.CANCELLED) + case Errored(ex) => outer.put( ("error.msg", ex.getMessage), ("error.stack", ex.getStackTrace.mkString("\n")) diff --git a/project/plugins.sbt b/project/plugins.sbt index 749621b1..392455c6 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,10 +1,11 @@ -addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.4") -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") -addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.8.0") -addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") -addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.14") -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1") -addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.6") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.1") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.4") +addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") +addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.8.0") +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") +addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.14") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1") +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.6") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.1") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") +addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") \ No newline at end of file From e7f8e7a1692270a1f140601e7662d21accf8aaba Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 13 Dec 2020 15:28:14 -0600 Subject: [PATCH 002/178] damnit sbt --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index 9525ad16..c1348805 100644 --- a/build.sbt +++ b/build.sbt @@ -95,6 +95,7 @@ lazy val commonSettings = Seq( ) // root project +commonSettings publish / skip := true lazy val core = crossProject(JSPlatform, JVMPlatform) From 15f30d5e27c1b8f960e58096167370662898c675 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 4 Jan 2021 13:54:16 -0600 Subject: [PATCH 003/178] m3 --- modules/datadog/src/main/scala/DDSpan.scala | 5 +++-- modules/noop/src/main/scala/NoopEntrypoint.scala | 2 +- modules/noop/src/main/scala/NoopSpan.scala | 2 +- modules/opencensus/src/main/scala/OpenCensus.scala | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/datadog/src/main/scala/DDSpan.scala b/modules/datadog/src/main/scala/DDSpan.scala index 88b0497a..2a45a844 100644 --- a/modules/datadog/src/main/scala/DDSpan.scala +++ b/modules/datadog/src/main/scala/DDSpan.scala @@ -6,7 +6,8 @@ package natchez package datadog import io.{opentracing => ot} -import cats.effect.{ExitCase, Resource, Sync} +import cats.effect.{Resource, Sync} +import cats.effect.Resource.ExitCase import cats.syntax.all._ import io.opentracing.propagation.{Format, TextMapAdapter} import natchez.TraceValue.{BooleanValue, NumberValue, StringValue} @@ -38,7 +39,7 @@ private[datadog] final case class DDSpan[F[_]: Sync]( def span(name: String): Resource[F,Span[F]] = Resource.makeCase( Sync[F].delay(tracer.buildSpan(name).asChildOf(span).start)) { - case (span, ExitCase.Error(e)) => Sync[F].delay(span.log(e.toString).finish()) + case (span, ExitCase.Errored(e)) => Sync[F].delay(span.log(e.toString).finish()) case (span, _) => Sync[F].delay(span.finish()) }.map(DDSpan(tracer, _)) diff --git a/modules/noop/src/main/scala/NoopEntrypoint.scala b/modules/noop/src/main/scala/NoopEntrypoint.scala index 75fcafca..14cf7aef 100644 --- a/modules/noop/src/main/scala/NoopEntrypoint.scala +++ b/modules/noop/src/main/scala/NoopEntrypoint.scala @@ -11,7 +11,7 @@ import cats.effect.Resource final case class NoopEntrypoint[F[_]: Applicative]() extends EntryPoint[F] { override def root(name: String): Resource[F, Span[F]] = { - Resource.liftF[F, Span[F]](Applicative[F].pure(NoopSpan())) + Resource.eval[F, Span[F]](Applicative[F].pure(NoopSpan())) } override def continue( diff --git a/modules/noop/src/main/scala/NoopSpan.scala b/modules/noop/src/main/scala/NoopSpan.scala index 8a15ec13..f5665198 100644 --- a/modules/noop/src/main/scala/NoopSpan.scala +++ b/modules/noop/src/main/scala/NoopSpan.scala @@ -19,7 +19,7 @@ final case class NoopSpan[F[_]: Applicative]() extends Span[F] { Applicative[F].pure(Kernel(Map.empty)) override def span(name: String): Resource[F, Span[F]] = - Resource.liftF(NoopSpan[F]().pure[F]) + Resource.eval(NoopSpan[F]().pure[F]) // TODO def traceId: F[Option[String]] = none.pure[F] diff --git a/modules/opencensus/src/main/scala/OpenCensus.scala b/modules/opencensus/src/main/scala/OpenCensus.scala index ddf61ae0..a1fd74bf 100644 --- a/modules/opencensus/src/main/scala/OpenCensus.scala +++ b/modules/opencensus/src/main/scala/OpenCensus.scala @@ -24,7 +24,7 @@ object OpenCensus { Sync[F].delay( OcAgentTraceExporter.unregister() )) - .flatMap(_ => Resource.liftF(entryPoint[F](sampler))) + .flatMap(_ => Resource.eval(entryPoint[F](sampler))) def entryPoint[F[_]: Sync](sampler: Sampler): F[EntryPoint[F]] = Sync[F] From ca9af3bc615ded37920945259146b9d1ec8d883d Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Thu, 28 Jan 2021 15:43:05 -0600 Subject: [PATCH 004/178] eviction check, disable odin --- build.sbt | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/build.sbt b/build.sbt index b95556fa..20157fd6 100644 --- a/build.sbt +++ b/build.sbt @@ -18,7 +18,9 @@ inThisBuild(Seq( "io.opentracing.contrib" % "*" % "always", "com.squareup.okhttp3" % "*" % "always", "com.squareup.okio" % "*" % "always", + "com.newrelic.telemetry" % "*" % "always", "org.typelevel" % "*" % "semver-spec", + "org.scala-js" % "*" % "semver-spec", ) )) @@ -330,18 +332,18 @@ lazy val mock = project // ).filterNot(_ => isDotty.value) // ) -lazy val logOdin = project - .in(file("modules/log-odin")) - .dependsOn(coreJVM) - .enablePlugins(AutomateHeaderPlugin) - .settings(commonSettings) - .settings( - publish / skip := isDotty.value, - name := "natchez-log-odin", - description := "Logging bindings for Natchez, using Odin.", - libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.13.0", - "com.github.valskalla" %% "odin-core" % "0.9.1", - "com.github.valskalla" %% "odin-json" % "0.9.1" - ).filterNot(_ => isDotty.value) - ) +// lazy val logOdin = project +// .in(file("modules/log-odin")) +// .dependsOn(coreJVM) +// .enablePlugins(AutomateHeaderPlugin) +// .settings(commonSettings) +// .settings( +// publish / skip := isDotty.value, +// name := "natchez-log-odin", +// description := "Logging bindings for Natchez, using Odin.", +// libraryDependencies ++= Seq( +// "io.circe" %% "circe-core" % "0.13.0", +// "com.github.valskalla" %% "odin-core" % "0.9.1", +// "com.github.valskalla" %% "odin-json" % "0.9.1" +// ).filterNot(_ => isDotty.value) +// ) From 3a84ae155db9c3a9743d99ae8755956ce52c34d7 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Sun, 21 Feb 2021 10:53:18 +0000 Subject: [PATCH 005/178] Update: cats effect, scalajs, collection compat, scala 3.0.0-RC1 --- build.sbt | 22 +++++++++++----------- project/plugins.sbt | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build.sbt b/build.sbt index 20157fd6..183fbaf0 100644 --- a/build.sbt +++ b/build.sbt @@ -1,11 +1,11 @@ val scala212Version = "2.12.12" val scala213Version = "2.13.4" -val scala30PreviousVersion = "3.0.0-M2" -val scala30Version = "3.0.0-M3" +val scala30PreviousVersion = "3.0.0-M3" +val scala30Version = "3.0.0-RC1" -val catsVersion = "2.3.1" -val catsEffectVersion = "3.0.0-M5" +val catsVersion = "2.4.2" +val catsEffectVersion = "3.0.0-RC2" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( @@ -140,7 +140,7 @@ lazy val jaeger = project name := "natchez-jaeger", description := "Jaeger support for Natchez.", libraryDependencies ++= Seq( - "org.scala-lang.modules" %% "scala-collection-compat" % (if (scalaVersion.value == "3.0.0-M2") "2.3.1" else "2.3.2"), + "org.scala-lang.modules" %% "scala-collection-compat" % "2.4.2", "io.jaegertracing" % "jaeger-client" % "1.5.0", ) ) @@ -154,7 +154,7 @@ lazy val honeycomb = project name := "natchez-honeycomb", description := "Honeycomb support for Natchez.", libraryDependencies ++= Seq( - "org.scala-lang.modules" %% "scala-collection-compat" % (if (scalaVersion.value == "3.0.0-M2") "2.3.1" else "2.3.2"), + "org.scala-lang.modules" %% "scala-collection-compat" % "2.4.2", "io.honeycomb.libhoney" % "libhoney-java" % "1.3.1" ) ) @@ -181,7 +181,7 @@ lazy val lightstep = project name := "natchez-lightstep", description := "Lightstep support for Natchez.", libraryDependencies ++= Seq( - "org.scala-lang.modules" %% "scala-collection-compat" % (if (scalaVersion.value == "3.0.0-M2") "2.3.1" else "2.3.2"), + "org.scala-lang.modules" %% "scala-collection-compat" % "2.4.2", "com.lightstep.tracer" % "lightstep-tracer-jre" % "0.30.3" ) ) @@ -223,7 +223,7 @@ lazy val datadog = project name := "natchez-datadog", description := "Lightstep HTTP bindings for Natchez.", libraryDependencies ++= Seq( - "org.scala-lang.modules" %% "scala-collection-compat" % (if (scalaVersion.value == "3.0.0-M2") "2.3.1" else "2.3.2"), + "org.scala-lang.modules" %% "scala-collection-compat" % "2.4.2", "com.datadoghq" % "dd-trace-ot" % "0.72.0", "com.datadoghq" % "dd-trace-api" % "0.72.0" ) @@ -262,7 +262,7 @@ lazy val newrelic = project description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( "io.circe" %% "circe-core" % "0.13.0", - "org.scala-lang.modules" %% "scala-collection-compat" % (if (scalaVersion.value == "3.0.0-M2") "2.3.1" else "2.3.2"), + "org.scala-lang.modules" %% "scala-collection-compat" % "2.4.2", "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.11.0", "com.newrelic.telemetry" % "telemetry-http-okhttp" % "0.11.0" @@ -277,7 +277,7 @@ lazy val mtl = crossProject(JSPlatform, JVMPlatform) name := "natchez-mtl", description := "cats-mtl bindings for Natchez.", libraryDependencies ++= Seq( - "org.typelevel" %%% "cats-mtl" % "1.1.1", + "org.typelevel" %%% "cats-mtl" % "1.1.2", ) ) @@ -310,7 +310,7 @@ lazy val mock = project description := "Mock Open Tracing implementation", libraryDependencies ++= Seq( "io.opentracing" % "opentracing-mock" % "0.33.0", - "org.scala-lang.modules" %% "scala-collection-compat" % (if (scalaVersion.value == "3.0.0-M2") "2.3.1" else "2.3.2"), + "org.scala-lang.modules" %% "scala-collection-compat" % "2.4.2" )) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4cef067b..13a91d62 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,7 +5,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.16") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1") -addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.2") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.4.0") +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.3") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") From 0279a731846065d045aa014358fb6c520c72a519 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 27 Apr 2021 14:05:38 -0500 Subject: [PATCH 006/178] merge with master --- build.sbt | 50 ++++++++++--------- .../src/main/{scala-2 => scala}/Log.scala | 2 +- .../src/main/{scala-2 => scala}/LogSpan.scala | 25 +++++----- .../src/test/scala}/LogSuite.scala | 4 +- .../src/test/scala}/MockLogger.scala | 4 +- project/build.properties | 2 +- 6 files changed, 46 insertions(+), 41 deletions(-) rename modules/log/shared/src/main/{scala-2 => scala}/Log.scala (95%) rename modules/log/shared/src/main/{scala-2 => scala}/LogSpan.scala (89%) rename modules/log/{jvm/src/test/scala-2 => shared/src/test/scala}/LogSuite.scala (95%) rename modules/log/{jvm/src/test/scala-2 => shared/src/test/scala}/MockLogger.scala (95%) diff --git a/build.sbt b/build.sbt index e52e83be..f20d88de 100644 --- a/build.sbt +++ b/build.sbt @@ -50,7 +50,7 @@ lazy val commonSettings = Seq( // Testing libraryDependencies ++= Seq( "org.scalameta" %%% "munit" % "0.7.25" % Test, - "org.typelevel" %%% "munit-cats-effect-2" % "1.0.2" % Test, + "org.typelevel" %%% "munit-cats-effect-3" % "1.0.2" % Test, ), testFrameworks += new TestFramework("munit.Framework"), @@ -206,7 +206,7 @@ lazy val lightstepGrpc = project libraryDependencies ++= Seq( "com.lightstep.tracer" % "tracer-grpc" % "0.30.3", "io.grpc" % "grpc-netty" % "1.37.0", - "io.netty" % "netty-tcnative-boringssl-static" % "2.0.38.Final" + "io.netty" % "netty-tcnative-boringssl-static" % "2.0.39.Final" ) ) @@ -254,27 +254,31 @@ lazy val datadog = project ) ) -// lazy val log = crossProject(JSPlatform, JVMPlatform) -// .in(file("modules/log")) -// .enablePlugins(AutomateHeaderPlugin) -// .settings(commonSettings) -// .settings(crossProjectSettings) -// .settings( -// publish / skip := isDotty.value, -// name := "natchez-log", -// description := "Logging bindings for Natchez, using log4cats.", -// libraryDependencies ++= Seq( -// "io.circe" %%% "circe-core" % "0.13.0", -// "io.chrisdavenport" %%% "log4cats-core" % "1.1.1", -// ).filterNot(_ => isDotty.value) -// ) -// lazy val logJVM = log.jvm.dependsOn(coreJVM) -// lazy val logJS = log.js.dependsOn(coreJS) -// .settings( -// scalaJSStage in Test := FastOptStage, -// jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(), -// scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), -// ) +lazy val log = crossProject(JSPlatform, JVMPlatform) + .in(file("modules/log")) + .enablePlugins(AutomateHeaderPlugin) + .settings(commonSettings) + .settings(crossProjectSettings) + .settings( + name := "natchez-log", + description := "Logging bindings for Natchez, using log4cats.", + libraryDependencies ++= Seq( + "io.circe" %%% "circe-core" % { + if (scalaVersion.value == scala30PreviousVersion) "0.14.0-M5" + else if (scalaVersion.value == scala30Version) "0.14.0-M6" + else "0.13.0" + }, + "org.typelevel" %%% "log4cats-core" % "2.1.0", + "io.github.cquiroz" %%% "scala-java-time" % "2.2.2" % Test, + ) + ) +lazy val logJVM = log.jvm.dependsOn(coreJVM) +lazy val logJS = log.js.dependsOn(coreJS) + .settings( + Test / scalaJSStage := FastOptStage, + jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(), + scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), + ) lazy val newrelic = project .in(file("modules/newrelic")) diff --git a/modules/log/shared/src/main/scala-2/Log.scala b/modules/log/shared/src/main/scala/Log.scala similarity index 95% rename from modules/log/shared/src/main/scala-2/Log.scala rename to modules/log/shared/src/main/scala/Log.scala index 1686ca56..1b3eceea 100644 --- a/modules/log/shared/src/main/scala-2/Log.scala +++ b/modules/log/shared/src/main/scala/Log.scala @@ -7,7 +7,7 @@ package log import cats.effect.{ Resource, Sync } import cats.syntax.functor._ -import io.chrisdavenport.log4cats.Logger +import org.typelevel.log4cats.Logger import io.circe.Json object Log { diff --git a/modules/log/shared/src/main/scala-2/LogSpan.scala b/modules/log/shared/src/main/scala/LogSpan.scala similarity index 89% rename from modules/log/shared/src/main/scala-2/LogSpan.scala rename to modules/log/shared/src/main/scala/LogSpan.scala index 3b3948b2..f35211d8 100644 --- a/modules/log/shared/src/main/scala-2/LogSpan.scala +++ b/modules/log/shared/src/main/scala/LogSpan.scala @@ -4,9 +4,10 @@ package natchez.log -import cats.effect.concurrent.Ref +import cats.effect.Ref import cats.effect._ -import cats.effect.ExitCase._ +import cats.effect.Resource.ExitCase +import cats.effect.Resource.ExitCase._ import cats.syntax.all._ import java.time.Instant import java.util.UUID @@ -16,7 +17,7 @@ import io.circe.Json import io.circe.Encoder import io.circe.syntax._ import io.circe.JsonObject -import io.chrisdavenport.log4cats.Logger +import org.typelevel.log4cats.Logger import java.net.URI private[log] final case class LogSpan[F[_]: Sync: Logger]( @@ -52,7 +53,7 @@ private[log] final case class LogSpan[F[_]: Sync: Logger]( def span(label: String): Resource[F, Span[F]] = Span.putErrorFields(Resource.makeCase(LogSpan.child(this, label))(LogSpan.finishChild[F]).widen) - def json(finish: Instant, exitCase: ExitCase[Throwable]): F[JsonObject] = + def json(finish: Instant, exitCase: ExitCase): F[JsonObject] = (fields.get, children.get).mapN { (fs, cs) => // Assemble our JSON object such that the Natchez fields always come first, in the same @@ -77,10 +78,10 @@ private[log] final case class LogSpan[F[_]: Sync: Logger]( "trace.trace_id" -> traceUUID.asJson, ) ++ { exitCase match { - case Completed => List("exit.case" -> "completed".asJson) - case Canceled => List("exit.case" -> "canceled".asJson) - case Error(ex: Fields) => exitFields(ex) ++ ex.fields.toList.map(_.map(_.asJson)) - case Error(ex) => exitFields(ex) + case Succeeded => List("exit.case" -> "succeeded".asJson) + case Canceled => List("exit.case" -> "canceled".asJson) + case Errored(ex: Fields) => exitFields(ex) ++ ex.fields.toList.map { case (k, v) => (k, v.asJson) } + case Errored(ex) => exitFields(ex) } } ++ fs ++ List("children" -> cs.reverse.map(Json.fromJsonObject).asJson) @@ -91,8 +92,8 @@ private[log] final case class LogSpan[F[_]: Sync: Logger]( def traceId: F[Option[String]] = traceUUID.toString.some.pure[F] - def spanId: F[Option[String]] = - sid.toString.some.pure[F] + def spanId: F[Option[String]] = + sid.toString.some.pure[F] def traceUri: F[Option[URI]] = none.pure[F] } @@ -127,7 +128,7 @@ private[log] object LogSpan { private def now[F[_]: Sync]: F[Instant] = Sync[F].delay(Instant.now) - def finish[F[_]: Sync: Logger](format: Json => String): (LogSpan[F], ExitCase[Throwable]) => F[Unit] = { (span, exitCase) => + def finish[F[_]: Sync: Logger](format: Json => String): (LogSpan[F], ExitCase) => F[Unit] = { (span, exitCase) => for { n <- now j <- span.json(n, exitCase) @@ -139,7 +140,7 @@ private[log] object LogSpan { } yield () } - def finishChild[F[_]: Sync: Logger]: (LogSpan[F], ExitCase[Throwable]) => F[Unit] = + def finishChild[F[_]: Sync: Logger]: (LogSpan[F], ExitCase) => F[Unit] = finish(_ => sys.error("implementation error; child JSON should never be logged")) def child[F[_]: Sync: Logger]( diff --git a/modules/log/jvm/src/test/scala-2/LogSuite.scala b/modules/log/shared/src/test/scala/LogSuite.scala similarity index 95% rename from modules/log/jvm/src/test/scala-2/LogSuite.scala rename to modules/log/shared/src/test/scala/LogSuite.scala index d4e5f9c4..b63a707a 100644 --- a/modules/log/jvm/src/test/scala-2/LogSuite.scala +++ b/modules/log/shared/src/test/scala/LogSuite.scala @@ -41,14 +41,14 @@ class LogSuite extends CatsEffectSuite { """|test: [info] { | "name" : "root span", | "service" : "service", - | "exit.case" : "completed", + | "exit.case" : "succeeded", | "foo" : 1, | "bar" : true, | "children" : [ | { | "name" : "child", | "service" : "service", - | "exit.case" : "completed", + | "exit.case" : "succeeded", | "baz" : "qux", | "children" : [ | ] diff --git a/modules/log/jvm/src/test/scala-2/MockLogger.scala b/modules/log/shared/src/test/scala/MockLogger.scala similarity index 95% rename from modules/log/jvm/src/test/scala-2/MockLogger.scala rename to modules/log/shared/src/test/scala/MockLogger.scala index 08021a27..d923d2ec 100644 --- a/modules/log/jvm/src/test/scala-2/MockLogger.scala +++ b/modules/log/shared/src/test/scala/MockLogger.scala @@ -5,9 +5,9 @@ package natchez package log -import io.chrisdavenport.log4cats.Logger +import org.typelevel.log4cats.Logger import cats.effect.Sync -import cats.effect.concurrent.Ref +import cats.effect.Ref import cats.syntax.all._ trait MockLogger[F[_]] extends Logger[F] { diff --git a/project/build.properties b/project/build.properties index e67343ae..f0be67b9 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.0 +sbt.version=1.5.1 From 96f5b5fe8a5cf18688817c347f21bbdb0e8e0601 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Thu, 22 Apr 2021 13:53:15 -0500 Subject: [PATCH 007/178] iotrace --- build.sbt | 28 ++++++++----------- .../core/shared/src/main/scala/Trace.scala | 27 ++++++++++++++++++ .../examples/src/main/scala-2/Example.scala | 21 +------------- .../main/scala-2/GlobalTracerExample.scala | 8 +++--- modules/examples/src/main/scala-2/Sort.scala | 6 ++-- 5 files changed, 46 insertions(+), 44 deletions(-) diff --git a/build.sbt b/build.sbt index f20d88de..15865080 100644 --- a/build.sbt +++ b/build.sbt @@ -343,23 +343,17 @@ lazy val mock = project )) -// lazy val examples = project -// .in(file("modules/examples")) -// .dependsOn(coreJVM, jaeger, honeycomb, lightstepHttp, datadog, logJVM, newrelic, logOdin) -// .enablePlugins(AutomateHeaderPlugin) -// .settings(commonSettings) -// .settings( -// publish / skip := true, -// name := "natchez-examples", -// description := "Example programs for Natchez.", -// scalacOptions -= "-Xfatal-warnings", -// libraryDependencies ++= Seq( -// "io.chrisdavenport" %% "log4cats-slf4j" % "1.1.1", -// "org.slf4j" % "slf4j-simple" % "1.7.30", -// "eu.timepit" %% "refined" % "0.9.19", -// "is.cir" %% "ciris" % "1.2.1" -// ).filterNot(_ => isDotty.value) -// ) +lazy val examples = project + .in(file("modules/examples")) + .dependsOn(coreJVM, jaeger, honeycomb, lightstepHttp, datadog, newrelic) + .enablePlugins(AutomateHeaderPlugin) + .settings(commonSettings) + .settings( + publish / skip := true, + name := "natchez-examples", + description := "Example programs for Natchez.", + scalacOptions -= "-Xfatal-warnings", + ) // lazy val logOdin = project // .in(file("modules/log-odin")) diff --git a/modules/core/shared/src/main/scala/Trace.scala b/modules/core/shared/src/main/scala/Trace.scala index cc1288e1..cee6f3fa 100644 --- a/modules/core/shared/src/main/scala/Trace.scala +++ b/modules/core/shared/src/main/scala/Trace.scala @@ -43,6 +43,33 @@ object Trace { def apply[F[_]](implicit ev: Trace[F]): ev.type = ev + /** A `Trace` instance that uses `IOLocal` internally. */ + def ioTrace(rootSpan: Span[IO]): IO[Trace[IO]] = + IOLocal(rootSpan).map { local => + new Trace[IO] { + + def put(fields: (String, TraceValue)*): IO[Unit] = + local.get.flatMap(_.put(fields: _*)) + + def kernel: IO[Kernel] = + local.get.flatMap(_.kernel) + + def span[A](name: String)(k: IO[A]): IO[A] = + local.get.flatMap { parent => + parent.span(name).flatMap { child => + Resource.make(local.set(child))(_ => local.set(parent)) + } .use { _ => k } + } + + def traceId: IO[Option[String]] = + local.get.flatMap(_.traceId) + + def traceUri: IO[Option[URI]] = + local.get.flatMap(_.traceUri) + + } + } + object Implicits { /** diff --git a/modules/examples/src/main/scala-2/Example.scala b/modules/examples/src/main/scala-2/Example.scala index a645f8f5..88b4869a 100644 --- a/modules/examples/src/main/scala-2/Example.scala +++ b/modules/examples/src/main/scala-2/Example.scala @@ -5,7 +5,6 @@ package example import cats._ -import cats.data.Kleisli import cats.effect._ import cats.syntax.all._ import natchez._ @@ -15,25 +14,7 @@ import java.net.URI object Main extends IOApp { -<<<<<<< HEAD - // Intentionally slow parallel quicksort, to demonstrate branching. If we run too quickly it seems - // to break Jaeger with "skipping clock skew adjustment" so let's pause a bit each time. - def qsort[F[_]: Parallel: Trace: Temporal, A: Order](as: List[A]): F[List[A]] = - Trace[F].span(as.mkString(",")) { - Temporal[F].sleep(10.milli) *> { - as match { - case Nil => Monad[F].pure(Nil) - case h :: t => - val (a, b) = t.partition(_ <= h) - (qsort[F, A](a), qsort[F, A](b)).parMapN(_ ++ List(h) ++ _) - } - } - } - def runF[F[_]: Async: Trace: Parallel]: F[Unit] = -======= - def runF[F[_]: Sync: Trace: Parallel: Timer]: F[Unit] = ->>>>>>> master Trace[F].span("Sort some stuff!") { for { as <- Sync[F].delay(List.fill(10)(Random.nextInt(1000))) @@ -132,7 +113,7 @@ object Main extends IOApp { def run(args: List[String]): IO[ExitCode] = { entryPoint[IO].use { ep => ep.root("this is the root span").use { span => - runF[Kleisli[IO, Span[IO], *]].run(span) + Trace.ioTrace(span).flatMap(implicit t => runF[IO]) } *> IO.sleep(1.second) // Turns out Tracer.close() in Jaeger doesn't block. Annoying. Maybe fix in there? } as ExitCode.Success } diff --git a/modules/examples/src/main/scala-2/GlobalTracerExample.scala b/modules/examples/src/main/scala-2/GlobalTracerExample.scala index 45ff017e..34988189 100644 --- a/modules/examples/src/main/scala-2/GlobalTracerExample.scala +++ b/modules/examples/src/main/scala-2/GlobalTracerExample.scala @@ -16,7 +16,7 @@ import java.net.URI object GlobalTracerMain extends IOApp { - def runF[F[_]: Sync: Trace: Parallel: Timer]: F[Unit] = + def runF[F[_]: Async: Trace: Parallel]: F[Unit] = Trace[F].span("Sort some stuff!") { for { as <- Sync[F].delay(List.fill(10)(Random.nextInt(1000))) @@ -30,7 +30,7 @@ object GlobalTracerMain extends IOApp { def globalTracerEntryPoint[F[_]: Sync]: F[Option[EntryPoint[F]]] = { // Datadog // import natchez.datadog.DDTracer - // val prefix = Some(new URI("https://app.datadoghq.com")) // https://app.datadoghq.eu for Europe + // val prefix = Some(new URI("https://app.datadoghq.com")) // https://app.datadoghq.eu for Europe // DDTracer.globalTracerEntryPoint[F](prefix) // Jaeger @@ -46,12 +46,12 @@ object GlobalTracerMain extends IOApp { def run(args: List[String]): IO[ExitCode] = { globalTracerEntryPoint[IO].flatMap { - case None => IO.delay { + case None => IO.delay { println("No tracer registered to the global tracer. Is your agent attached with tracing enabled?") } as ExitCode.Error case Some(ep) => ep.root("this is the root span") - .use(span => runF[Kleisli[IO, Span[IO], *]].run(span)) *> + .use(span => runF[Kleisli[IO, Span[IO], *]].run(span)) *> IO.sleep(1.second) as ExitCode.Success // Turns out Tracer.close() in Jaeger doesn't block. Annoying. Maybe fix in there? } } diff --git a/modules/examples/src/main/scala-2/Sort.scala b/modules/examples/src/main/scala-2/Sort.scala index 7dc41229..296f880a 100644 --- a/modules/examples/src/main/scala-2/Sort.scala +++ b/modules/examples/src/main/scala-2/Sort.scala @@ -5,7 +5,7 @@ package example import cats._ -import cats.effect.Timer +import cats.effect.Temporal import cats.syntax.all._ import natchez.Trace import scala.concurrent.duration._ @@ -14,9 +14,9 @@ object Sort { // Intentionally slow parallel quicksort, to demonstrate branching. If we run too quickly it seems // to break Jaeger with "skipping clock skew adjustment" so let's pause a bit each time. - def qsort[F[_]: Monad: Parallel: Trace: Timer, A: Order](as: List[A]): F[List[A]] = + def qsort[F[_]: Parallel: Trace: Temporal, A: Order](as: List[A]): F[List[A]] = Trace[F].span(as.mkString(",")) { - Timer[F].sleep(10.milli) *> { + Temporal[F].sleep(10.milli) *> { as match { case Nil => Monad[F].pure(Nil) case h :: t => From 55d6a0de4350eb561d587849861d094feb424fba Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 17 May 2021 12:20:33 -0500 Subject: [PATCH 008/178] evictions --- build.sbt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.sbt b/build.sbt index b12f18c6..0ca23941 100644 --- a/build.sbt +++ b/build.sbt @@ -22,6 +22,12 @@ inThisBuild(Seq( "org.typelevel" % "*" % "semver-spec", "org.scala-js" % "*" % "semver-spec", "org.jctools" % "*" % "always", + "org.jetbrains" % "*" % "always", + "org.jboss.logging" % "*" % "always", + "org.jboss.threads" % "*" % "always", + "org.wildfly.common" % "*" % "always", + "org.jboss.xnio" % "*" % "always", + "com.lihaoyi" % "*" % "always", ) )) From e6e33c381108eb9bf27476c4e7036ab6e0a8e38c Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 26 May 2021 10:10:26 -0500 Subject: [PATCH 009/178] re-enable examples for Scala 3 --- build.sbt | 2 +- .../examples/src/main/scala-2/Example.scala | 123 ------------------ .../main/scala-2/GlobalTracerExample.scala | 60 --------- .../src/main/scala-2/NewrelicExample.scala | 61 --------- modules/examples/src/main/scala-2/Sort.scala | 28 ---- 5 files changed, 1 insertion(+), 273 deletions(-) delete mode 100644 modules/examples/src/main/scala-2/Example.scala delete mode 100644 modules/examples/src/main/scala-2/GlobalTracerExample.scala delete mode 100644 modules/examples/src/main/scala-2/NewrelicExample.scala delete mode 100644 modules/examples/src/main/scala-2/Sort.scala diff --git a/build.sbt b/build.sbt index a2213912..9f954947 100644 --- a/build.sbt +++ b/build.sbt @@ -338,7 +338,7 @@ lazy val examples = project "org.slf4j" % "slf4j-simple" % "1.7.30", "eu.timepit" %% "refined" % "0.9.25", "is.cir" %% "ciris" % "2.0.0" - ).filterNot(_ => scalaVersion.value.startsWith("3.")) + ) ) // lazy val logOdin = project diff --git a/modules/examples/src/main/scala-2/Example.scala b/modules/examples/src/main/scala-2/Example.scala deleted file mode 100644 index a17c4db6..00000000 --- a/modules/examples/src/main/scala-2/Example.scala +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (c) 2019-2020 by Rob Norris and Contributors -// This software is licensed under the MIT License (MIT). -// For more information see LICENSE or https://opensource.org/licenses/MIT - -package example - -import cats._ -import cats.effect._ -import cats.syntax.all._ -import natchez._ -import scala.util.Random -import scala.concurrent.duration._ -// import java.net.URI - -object Main extends IOApp { - - def runF[F[_]: Async: Trace: Parallel]: F[Unit] = - Trace[F].span("Sort some stuff!") { - for { - as <- Sync[F].delay(List.fill(10)(Random.nextInt(5))) - _ <- Sort.qsort[F, Int](as) - u <- Trace[F].traceUri - _ <- u.traverse(uri => Sync[F].delay(println(s"View this trace at $uri"))) - _ <- Sync[F].delay(println("Done.")) - } yield () - } - - // For Honeycomb you would say - // def entryPoint[F[_]: Sync]: Resource[F, EntryPoint[F]] = - // Honeycomb.entryPoint[F]("natchez-example") { ob => - // Sync[F].delay { - // ob.setWriteKey("") - // .setDataset("") - // .build - // } - // } - - // The following would be the minimal entrypoint setup for Lightstep. Note that - // by default examples project uses lightstep HTTP binding. To change that, - // edit the project dependencies. - // def entryPoint[F[_]: Sync]: Resource[F, EntryPoint[F]] = - // Lightstep.entryPoint[F] { ob => - // Sync[F].delay { - // val options = ob - // .withAccessToken("") - // .withComponentName("") - // .withCollectorHost("") - // .withCollectorProtocol("") - // .withCollectorPort() - // .build() - // - // new JRETracer(options) - // } - // } - -// DataDog -// def entryPoint[F[_]: Sync]: Resource[F, EntryPoint[F]] = { -// import java.util.Properties -// import natchez.datadog.DDTracer -// DDTracer.entryPoint[F]( -// buildFunc = -// builder => -// Sync[F].delay( -// builder.withProperties( -// new Properties() { -// put("writer.type", "LoggingWriter") -// } -// ).serviceName("natchez-sample").build() -// ), -// uriPrefix = Some(new URI("https://app.datadoghq.com")) // https://app.datadoghq.eu for Europe -// ) -// } - - // Jaeger - // def entryPoint[F[_]: Sync]: Resource[F, EntryPoint[F]] = { - // import natchez.jaeger.Jaeger - // import io.jaegertracing.Configuration.SamplerConfiguration - // import io.jaegertracing.Configuration.ReporterConfiguration - // Jaeger.entryPoint[F]( - // system = "natchez-example", - // uriPrefix = Some(new URI("http://localhost:16686")), - // ) { c => - // Sync[F].delay { - // c.withSampler(SamplerConfiguration.fromEnv) - // .withReporter(ReporterConfiguration.fromEnv) - // .getTracer - // } - // } - // }å - - // Log - def entryPoint[F[_]: Sync]: Resource[F, EntryPoint[F]] = { - import natchez.log.Log - import org.typelevel.log4cats.Logger - import org.typelevel.log4cats.slf4j.Slf4jLogger - implicit val log: Logger[F] = Slf4jLogger.getLogger[F] - Log.entryPoint[F]("foo").pure[Resource[F, *]] - } - - // Log with Odin - // def entryPoint[F[_]: Sync: Timer]: Resource[F, EntryPoint[F]] = { - // import natchez.logodin.Log - // import io.odin.Logger - // import io.odin.consoleLogger - // import io.odin.{Level, formatter} - // implicit val log: Logger[F] = consoleLogger[F]( - // formatter = formatter.Formatter.colorful, - // minLevel = Level.Info - // ) - // Log.entryPoint[F]("foo").pure[Resource[F, *]] - // } - - def run(args: List[String]): IO[ExitCode] = { - entryPoint[IO].use { ep => - ep.root("this is the root span").use { span => - Trace.ioTrace(span).flatMap(implicit t => runF[IO]) - } *> IO.sleep(1.second) // Turns out Tracer.close() in Jaeger doesn't block. Annoying. Maybe fix in there? - } as ExitCode.Success - } - -} - - diff --git a/modules/examples/src/main/scala-2/GlobalTracerExample.scala b/modules/examples/src/main/scala-2/GlobalTracerExample.scala deleted file mode 100644 index 34988189..00000000 --- a/modules/examples/src/main/scala-2/GlobalTracerExample.scala +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2019-2020 by Rob Norris and Contributors -// This software is licensed under the MIT License (MIT). -// For more information see LICENSE or https://opensource.org/licenses/MIT - -package example - -import cats._ -import cats.data.Kleisli -import cats.effect._ -import cats.syntax.all._ -import natchez._ -import scala.util.Random -import scala.concurrent.duration._ -import java.net.URI - - -object GlobalTracerMain extends IOApp { - - def runF[F[_]: Async: Trace: Parallel]: F[Unit] = - Trace[F].span("Sort some stuff!") { - for { - as <- Sync[F].delay(List.fill(10)(Random.nextInt(1000))) - _ <- Sort.qsort[F, Int](as) - u <- Trace[F].traceUri - _ <- u.traverse(uri => Sync[F].delay(println(s"View this trace at $uri"))) - _ <- Sync[F].delay(println("Done.")) - } yield () - } - - def globalTracerEntryPoint[F[_]: Sync]: F[Option[EntryPoint[F]]] = { - // Datadog - // import natchez.datadog.DDTracer - // val prefix = Some(new URI("https://app.datadoghq.com")) // https://app.datadoghq.eu for Europe - // DDTracer.globalTracerEntryPoint[F](prefix) - - // Jaeger - import natchez.jaeger.Jaeger - val prefix = Some(new URI("http://localhost:16686")) - Jaeger.globalTracerEntryPoint[F](prefix) - - // Lightstep - // import natchez.lightstep.Lightstep - // Lightstep.globalTracerEntryPoint[F] - - } - - def run(args: List[String]): IO[ExitCode] = { - globalTracerEntryPoint[IO].flatMap { - case None => IO.delay { - println("No tracer registered to the global tracer. Is your agent attached with tracing enabled?") - } as ExitCode.Error - case Some(ep) => - ep.root("this is the root span") - .use(span => runF[Kleisli[IO, Span[IO], *]].run(span)) *> - IO.sleep(1.second) as ExitCode.Success // Turns out Tracer.close() in Jaeger doesn't block. Annoying. Maybe fix in there? - } - } - - -} diff --git a/modules/examples/src/main/scala-2/NewrelicExample.scala b/modules/examples/src/main/scala-2/NewrelicExample.scala deleted file mode 100644 index f18ecf49..00000000 --- a/modules/examples/src/main/scala-2/NewrelicExample.scala +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2019-2020 by Rob Norris and Contributors -// This software is licensed under the MIT License (MIT). -// For more information see LICENSE or https://opensource.org/licenses/MIT - -// import cats._ -// import cats.data.Kleisli -// import cats.effect._ -// import cats.implicits._ -// import com.newrelic.telemetry.SimpleSpanBatchSender -// import natchez._ -// import natchez.newrelic.NewRelic - -// import scala.util.Random -// import scala.concurrent.duration._ - -// object NewrelicExample extends IOApp { - -// // Intentionally slow parallel quicksort, to demonstrate branching. If we run too quickly it seems -// // to break Jaeger with "skipping clock skew adjustment" so let's pause a bit each time. -// def qsort[F[_]: Monad: Parallel: Trace: Timer, A: Order](as: List[A]): F[List[A]] = -// Trace[F].span(as.mkString(",")) { -// Timer[F].sleep(10.milli) *> { -// as match { -// case Nil => Monad[F].pure(Nil) -// case h :: t => -// val (a, b) = t.partition(_ <= h) -// (qsort[F, A](a), qsort[F, A](b)).parMapN(_ ++ List(h) ++ _) -// } -// } -// } - -// def runF[F[_]: Sync: Trace: Parallel: Timer]: F[Unit] = -// Trace[F].span("Sort some stuff!") { -// for { -// as <- Sync[F].delay(List.fill(100)(Random.nextInt(1000))) -// _ <- qsort[F, Int](as) -// } yield () -// } - -// // Jaeger -// def entryPoint[F[_]: Sync](apiKey: String): EntryPoint[F] = -// NewRelic.entryPoint[F]("qsort_example") { - -// SimpleSpanBatchSender -// .builder(apiKey, java.time.Duration.ofSeconds(5)) -// .enableAuditLogging() -// .build() -// } - -// def run(args: List[String]): IO[ExitCode] = -// ciris -// .env("NR_API_KEY") -// .load[IO] -// .flatMap( -// apiKey => -// entryPoint[IO](apiKey) -// .root("this is the root span") -// .use(span => runF[Kleisli[IO, Span[IO], *]].run(span)) -// .as(ExitCode.Success)) - -// } diff --git a/modules/examples/src/main/scala-2/Sort.scala b/modules/examples/src/main/scala-2/Sort.scala deleted file mode 100644 index 296f880a..00000000 --- a/modules/examples/src/main/scala-2/Sort.scala +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2019-2020 by Rob Norris and Contributors -// This software is licensed under the MIT License (MIT). -// For more information see LICENSE or https://opensource.org/licenses/MIT - -package example - -import cats._ -import cats.effect.Temporal -import cats.syntax.all._ -import natchez.Trace -import scala.concurrent.duration._ - -object Sort { - - // Intentionally slow parallel quicksort, to demonstrate branching. If we run too quickly it seems - // to break Jaeger with "skipping clock skew adjustment" so let's pause a bit each time. - def qsort[F[_]: Parallel: Trace: Temporal, A: Order](as: List[A]): F[List[A]] = - Trace[F].span(as.mkString(",")) { - Temporal[F].sleep(10.milli) *> { - as match { - case Nil => Monad[F].pure(Nil) - case h :: t => - val (a, b) = t.partition(_ <= h) - (qsort[F, A](a), qsort[F, A](b)).parMapN(_ ++ List(h) ++ _) - } - } - } -} From 62c1a50b346914b91d4b880845f795254c54589f Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 26 May 2021 10:25:55 -0500 Subject: [PATCH 010/178] get doc working with ce3 --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 1 - modules/docs/src/main/paradox/backends/log.md | 1 + .../src/main/paradox/reference/entrypoints.md | 2 +- .../src/main/paradox/reference/kernels.md | 5 +- .../docs/src/main/paradox/reference/trace.md | 12 +- modules/docs/src/main/scala/Junk.scala | 27 ++-- modules/examples/src/main/scala/Example.scala | 123 ++++++++++++++++++ .../src/main/scala/GlobalTracerExample.scala | 60 +++++++++ .../src/main/scala/NewrelicExample.scala | 61 +++++++++ modules/examples/src/main/scala/Sort.scala | 28 ++++ 11 files changed, 299 insertions(+), 23 deletions(-) create mode 100644 modules/examples/src/main/scala/Example.scala create mode 100644 modules/examples/src/main/scala/GlobalTracerExample.scala create mode 100644 modules/examples/src/main/scala/NewrelicExample.scala create mode 100644 modules/examples/src/main/scala/Sort.scala diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 01b565ec..49441624 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,4 +17,4 @@ jobs: ~/.sbt key: sbt-${{ hashFiles('**/build.sbt') }} - name: Run tests - run: sbt headerCheck +clean +test + run: sbt headerCheck +clean +test docs/makeSite diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 86fe0744..dc59c065 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,6 @@ name: Release on: push: - branches: [master] tags: ["*"] jobs: publish: diff --git a/modules/docs/src/main/paradox/backends/log.md b/modules/docs/src/main/paradox/backends/log.md index bccdec17..8df0b9a3 100644 --- a/modules/docs/src/main/paradox/backends/log.md +++ b/modules/docs/src/main/paradox/backends/log.md @@ -14,6 +14,7 @@ The log handler constructs a JSON object for each root span, with a `children` c ```scala mdoc:passthrough import cats.effect._ +import cats.effect.unsafe.implicits.global import cats.syntax.all._ import org.typelevel.log4cats.Logger import natchez.log.Log diff --git a/modules/docs/src/main/paradox/reference/entrypoints.md b/modules/docs/src/main/paradox/reference/entrypoints.md index e76f84f9..4ec90bc3 100644 --- a/modules/docs/src/main/paradox/reference/entrypoints.md +++ b/modules/docs/src/main/paradox/reference/entrypoints.md @@ -45,7 +45,7 @@ def continuedRoutes(ep: EntryPoint[IO]): HttpRoutes[IO] = case req@(GET -> Root / "hello" / name) => val k: Kernel = - Kernel(req.headers.toList.map { h => h.name.value -> h.value }.toMap) + Kernel(req.headers.headers.map { h => h.name.toString -> h.value }.toMap) ep.continueOrElseRoot("hello", k).use { span => span.put("the-name" -> name) *> diff --git a/modules/docs/src/main/paradox/reference/kernels.md b/modules/docs/src/main/paradox/reference/kernels.md index 12d70718..3199a250 100644 --- a/modules/docs/src/main/paradox/reference/kernels.md +++ b/modules/docs/src/main/paradox/reference/kernels.md @@ -16,6 +16,7 @@ import org.http4s.{ EntityDecoder, Uri, Header } import org.http4s.Method.GET import org.http4s.client.Client import org.http4s.client.dsl.io._ +import org.typelevel.ci.CIString ``` We can add a `Span`'s kernel to an outgoing `Client` request. If the remote server supports tracing via the same back end, it can extend the trace with child spans. @@ -26,8 +27,8 @@ def makeRequest[A](span: Span[IO], client: Client[IO], uri: Uri)( ): IO[A] = span.kernel.flatMap { k => // turn a Map[String, String] into List[Header] - val http4sHeaders = k.toHeaders.map { case (k, v) => Header(k, v) } .toSeq - client.expect[A](GET(uri, http4sHeaders: _*)) + val http4sHeaders = k.toHeaders.map { case (k, v) => Header.Raw(CIString(k), v) } .toSeq + client.expect[A](GET(uri).withHeaders(http4sHeaders)) } ``` diff --git a/modules/docs/src/main/paradox/reference/trace.md b/modules/docs/src/main/paradox/reference/trace.md index 33940b33..f1b304bd 100644 --- a/modules/docs/src/main/paradox/reference/trace.md +++ b/modules/docs/src/main/paradox/reference/trace.md @@ -8,7 +8,7 @@ _The examples on this page use the following imports:_ ```scala mdoc import cats.{ Applicative, Monad } import cats.data.Kleisli -import cats.effect.Bracket +import cats.effect.MonadCancel import cats.mtl.Local import cats.syntax.all._ import natchez.{ Span, Trace } @@ -50,12 +50,12 @@ object NoTraceForYou { ## Kleisli Instance -Given `Bracket[F, Throwable]` there is a `Trace[F]` instance for `Kleisli[F, Span[F], *]`. This allows us to discharge a `Trace` constraint, given an initial `Span`. +Given `MonadCancel[F, Throwable]` there is a `Trace[F]` instance for `Kleisli[F, Span[F], *]`. This allows us to discharge a `Trace` constraint, given an initial `Span`. ```scala mdoc -// Given Bracket[F, Throwable] and a Span[F] we can call `wibble` +// Given MonadCancel[F, Throwable] and a Span[F] we can call `wibble` def go[F[_]](span: Span[F])( - implicit ev: Bracket[F, Throwable] + implicit ev: MonadCancel[F, Throwable] ): F[Unit] = wibble[Kleisli[F, Span[F], *]]("bob", 42).run(span) ``` @@ -68,11 +68,11 @@ It is not always possible instantiate arbitrary `F` as `Kleisli`, depending on t ## Cats-MTL Local Instance -By first adding the `natchez-mtl` module (which pulls in Cats-MTL), given `Bracket[F, Throwable]` and `Local[F, Span[F]]` there is an instance `Trace[F]`. +By first adding the `natchez-mtl` module (which pulls in Cats-MTL), given `MonadCancel[F, Throwable]` and `Local[F, Span[F]]` there is an instance `Trace[F]`. ```scala mdoc def goLocal[F[_]]( - implicit ev0: Bracket[F, Throwable], + implicit ev0: MonadCancel[F, Throwable], ev1: Local[F, Span[F]] ): F[Unit] = wibble("bob", 42) diff --git a/modules/docs/src/main/scala/Junk.scala b/modules/docs/src/main/scala/Junk.scala index f697b088..885589df 100644 --- a/modules/docs/src/main/scala/Junk.scala +++ b/modules/docs/src/main/scala/Junk.scala @@ -2,20 +2,23 @@ // This software is licensed under the MIT License (MIT). // For more information see LICENSE or https://opensource.org/licenses/MIT -package junk - import cats.effect.IO -import natchez.EntryPoint -import natchez.log.Log -import org.typelevel.log4cats.Logger -import org.typelevel.log4cats.slf4j.Slf4jLogger - -object Junk { +import natchez.{ Span } +import org.http4s.{ EntityDecoder, Uri, Header } +import org.http4s.Method.GET +import org.http4s.client.Client +import org.http4s.client.dsl.io._ +import org.typelevel.ci.CIString - implicit val log: Logger[IO] = - Slf4jLogger.getLoggerFromName("example-logger") +object X { - val ep: EntryPoint[IO] = - Log.entryPoint[IO]("example-service") + def makeRequest[A](span: Span[IO], client: Client[IO], uri: Uri)( + implicit ev: EntityDecoder[IO, A] + ): IO[A] = + span.kernel.flatMap { k => + // turn a Map[String, String] into List[Header] + val http4sHeaders = k.toHeaders.map { case (k, v) => Header.Raw(CIString(k), v) } .toSeq + client.expect[A](GET(uri).withHeaders(http4sHeaders)) + } } \ No newline at end of file diff --git a/modules/examples/src/main/scala/Example.scala b/modules/examples/src/main/scala/Example.scala new file mode 100644 index 00000000..a17c4db6 --- /dev/null +++ b/modules/examples/src/main/scala/Example.scala @@ -0,0 +1,123 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package example + +import cats._ +import cats.effect._ +import cats.syntax.all._ +import natchez._ +import scala.util.Random +import scala.concurrent.duration._ +// import java.net.URI + +object Main extends IOApp { + + def runF[F[_]: Async: Trace: Parallel]: F[Unit] = + Trace[F].span("Sort some stuff!") { + for { + as <- Sync[F].delay(List.fill(10)(Random.nextInt(5))) + _ <- Sort.qsort[F, Int](as) + u <- Trace[F].traceUri + _ <- u.traverse(uri => Sync[F].delay(println(s"View this trace at $uri"))) + _ <- Sync[F].delay(println("Done.")) + } yield () + } + + // For Honeycomb you would say + // def entryPoint[F[_]: Sync]: Resource[F, EntryPoint[F]] = + // Honeycomb.entryPoint[F]("natchez-example") { ob => + // Sync[F].delay { + // ob.setWriteKey("") + // .setDataset("") + // .build + // } + // } + + // The following would be the minimal entrypoint setup for Lightstep. Note that + // by default examples project uses lightstep HTTP binding. To change that, + // edit the project dependencies. + // def entryPoint[F[_]: Sync]: Resource[F, EntryPoint[F]] = + // Lightstep.entryPoint[F] { ob => + // Sync[F].delay { + // val options = ob + // .withAccessToken("") + // .withComponentName("") + // .withCollectorHost("") + // .withCollectorProtocol("") + // .withCollectorPort() + // .build() + // + // new JRETracer(options) + // } + // } + +// DataDog +// def entryPoint[F[_]: Sync]: Resource[F, EntryPoint[F]] = { +// import java.util.Properties +// import natchez.datadog.DDTracer +// DDTracer.entryPoint[F]( +// buildFunc = +// builder => +// Sync[F].delay( +// builder.withProperties( +// new Properties() { +// put("writer.type", "LoggingWriter") +// } +// ).serviceName("natchez-sample").build() +// ), +// uriPrefix = Some(new URI("https://app.datadoghq.com")) // https://app.datadoghq.eu for Europe +// ) +// } + + // Jaeger + // def entryPoint[F[_]: Sync]: Resource[F, EntryPoint[F]] = { + // import natchez.jaeger.Jaeger + // import io.jaegertracing.Configuration.SamplerConfiguration + // import io.jaegertracing.Configuration.ReporterConfiguration + // Jaeger.entryPoint[F]( + // system = "natchez-example", + // uriPrefix = Some(new URI("http://localhost:16686")), + // ) { c => + // Sync[F].delay { + // c.withSampler(SamplerConfiguration.fromEnv) + // .withReporter(ReporterConfiguration.fromEnv) + // .getTracer + // } + // } + // }å + + // Log + def entryPoint[F[_]: Sync]: Resource[F, EntryPoint[F]] = { + import natchez.log.Log + import org.typelevel.log4cats.Logger + import org.typelevel.log4cats.slf4j.Slf4jLogger + implicit val log: Logger[F] = Slf4jLogger.getLogger[F] + Log.entryPoint[F]("foo").pure[Resource[F, *]] + } + + // Log with Odin + // def entryPoint[F[_]: Sync: Timer]: Resource[F, EntryPoint[F]] = { + // import natchez.logodin.Log + // import io.odin.Logger + // import io.odin.consoleLogger + // import io.odin.{Level, formatter} + // implicit val log: Logger[F] = consoleLogger[F]( + // formatter = formatter.Formatter.colorful, + // minLevel = Level.Info + // ) + // Log.entryPoint[F]("foo").pure[Resource[F, *]] + // } + + def run(args: List[String]): IO[ExitCode] = { + entryPoint[IO].use { ep => + ep.root("this is the root span").use { span => + Trace.ioTrace(span).flatMap(implicit t => runF[IO]) + } *> IO.sleep(1.second) // Turns out Tracer.close() in Jaeger doesn't block. Annoying. Maybe fix in there? + } as ExitCode.Success + } + +} + + diff --git a/modules/examples/src/main/scala/GlobalTracerExample.scala b/modules/examples/src/main/scala/GlobalTracerExample.scala new file mode 100644 index 00000000..34988189 --- /dev/null +++ b/modules/examples/src/main/scala/GlobalTracerExample.scala @@ -0,0 +1,60 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package example + +import cats._ +import cats.data.Kleisli +import cats.effect._ +import cats.syntax.all._ +import natchez._ +import scala.util.Random +import scala.concurrent.duration._ +import java.net.URI + + +object GlobalTracerMain extends IOApp { + + def runF[F[_]: Async: Trace: Parallel]: F[Unit] = + Trace[F].span("Sort some stuff!") { + for { + as <- Sync[F].delay(List.fill(10)(Random.nextInt(1000))) + _ <- Sort.qsort[F, Int](as) + u <- Trace[F].traceUri + _ <- u.traverse(uri => Sync[F].delay(println(s"View this trace at $uri"))) + _ <- Sync[F].delay(println("Done.")) + } yield () + } + + def globalTracerEntryPoint[F[_]: Sync]: F[Option[EntryPoint[F]]] = { + // Datadog + // import natchez.datadog.DDTracer + // val prefix = Some(new URI("https://app.datadoghq.com")) // https://app.datadoghq.eu for Europe + // DDTracer.globalTracerEntryPoint[F](prefix) + + // Jaeger + import natchez.jaeger.Jaeger + val prefix = Some(new URI("http://localhost:16686")) + Jaeger.globalTracerEntryPoint[F](prefix) + + // Lightstep + // import natchez.lightstep.Lightstep + // Lightstep.globalTracerEntryPoint[F] + + } + + def run(args: List[String]): IO[ExitCode] = { + globalTracerEntryPoint[IO].flatMap { + case None => IO.delay { + println("No tracer registered to the global tracer. Is your agent attached with tracing enabled?") + } as ExitCode.Error + case Some(ep) => + ep.root("this is the root span") + .use(span => runF[Kleisli[IO, Span[IO], *]].run(span)) *> + IO.sleep(1.second) as ExitCode.Success // Turns out Tracer.close() in Jaeger doesn't block. Annoying. Maybe fix in there? + } + } + + +} diff --git a/modules/examples/src/main/scala/NewrelicExample.scala b/modules/examples/src/main/scala/NewrelicExample.scala new file mode 100644 index 00000000..f18ecf49 --- /dev/null +++ b/modules/examples/src/main/scala/NewrelicExample.scala @@ -0,0 +1,61 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +// import cats._ +// import cats.data.Kleisli +// import cats.effect._ +// import cats.implicits._ +// import com.newrelic.telemetry.SimpleSpanBatchSender +// import natchez._ +// import natchez.newrelic.NewRelic + +// import scala.util.Random +// import scala.concurrent.duration._ + +// object NewrelicExample extends IOApp { + +// // Intentionally slow parallel quicksort, to demonstrate branching. If we run too quickly it seems +// // to break Jaeger with "skipping clock skew adjustment" so let's pause a bit each time. +// def qsort[F[_]: Monad: Parallel: Trace: Timer, A: Order](as: List[A]): F[List[A]] = +// Trace[F].span(as.mkString(",")) { +// Timer[F].sleep(10.milli) *> { +// as match { +// case Nil => Monad[F].pure(Nil) +// case h :: t => +// val (a, b) = t.partition(_ <= h) +// (qsort[F, A](a), qsort[F, A](b)).parMapN(_ ++ List(h) ++ _) +// } +// } +// } + +// def runF[F[_]: Sync: Trace: Parallel: Timer]: F[Unit] = +// Trace[F].span("Sort some stuff!") { +// for { +// as <- Sync[F].delay(List.fill(100)(Random.nextInt(1000))) +// _ <- qsort[F, Int](as) +// } yield () +// } + +// // Jaeger +// def entryPoint[F[_]: Sync](apiKey: String): EntryPoint[F] = +// NewRelic.entryPoint[F]("qsort_example") { + +// SimpleSpanBatchSender +// .builder(apiKey, java.time.Duration.ofSeconds(5)) +// .enableAuditLogging() +// .build() +// } + +// def run(args: List[String]): IO[ExitCode] = +// ciris +// .env("NR_API_KEY") +// .load[IO] +// .flatMap( +// apiKey => +// entryPoint[IO](apiKey) +// .root("this is the root span") +// .use(span => runF[Kleisli[IO, Span[IO], *]].run(span)) +// .as(ExitCode.Success)) + +// } diff --git a/modules/examples/src/main/scala/Sort.scala b/modules/examples/src/main/scala/Sort.scala new file mode 100644 index 00000000..296f880a --- /dev/null +++ b/modules/examples/src/main/scala/Sort.scala @@ -0,0 +1,28 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package example + +import cats._ +import cats.effect.Temporal +import cats.syntax.all._ +import natchez.Trace +import scala.concurrent.duration._ + +object Sort { + + // Intentionally slow parallel quicksort, to demonstrate branching. If we run too quickly it seems + // to break Jaeger with "skipping clock skew adjustment" so let's pause a bit each time. + def qsort[F[_]: Parallel: Trace: Temporal, A: Order](as: List[A]): F[List[A]] = + Trace[F].span(as.mkString(",")) { + Temporal[F].sleep(10.milli) *> { + as match { + case Nil => Monad[F].pure(Nil) + case h :: t => + val (a, b) = t.partition(_ <= h) + (qsort[F, A](a), qsort[F, A](b)).parMapN(_ ++ List(h) ++ _) + } + } + } +} From 0d2a2ad7559fb998f6a22b7c83f7fdcb1a1948c3 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 26 May 2021 10:59:50 -0500 Subject: [PATCH 011/178] update index --- modules/docs/src/main/paradox/index.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/docs/src/main/paradox/index.md b/modules/docs/src/main/paradox/index.md index 03a76e75..20ba9bda 100644 --- a/modules/docs/src/main/paradox/index.md +++ b/modules/docs/src/main/paradox/index.md @@ -24,6 +24,13 @@ _Credits: [Wikipedia](https://en.wikipedia.org/wiki/Natchez_Trace) and the [Nati **Natchez** is a minimal distributed tracing library for Cats, inspired by earlier work done on [puretracing](https://github.com/tabdulradi/puretracing). Natchez is published for **Scala $scala-versions$**, with limited support for Scala-JS. +Below are the available version series (see [releases](https://github.com/tpolecat/natchez/releases) for exact version numbers). You are strongly encouraged to use the **Active** series. Older series will receive bug fixes when necessary but are not actively maintained. + +| Series | Status | 2.12 | 2.13 | 3.0 | Cats-Effect | +|:---------:|------------|:----:|:----:|:---:|:-----------:| +| **0.1.x** | **Active** | ✅ | ✅ | ✅ | **3.x** | +| 0.0.x | EOL | ✅ | ✅ | ✅ | 2.x | + ## Quick Start 1. Choose your dependency: @@ -52,13 +59,10 @@ _Credits: [Wikipedia](https://en.wikipedia.org/wiki/Natchez_Trace) and the [Nati ## How to Contribute +This is a community-supported project and contributions are welcome! + - If you see a typo in the doc, click the link at the bottom and fix it! - If you find a bug please open an issue (or fix it and open a PR) at our [GitHub Repository](https://github.com/tpolecat/natchez). - If you want to make a larger contribution, please open an issue first so we can discuss. -Note that there are two active version series right now: - -- Versions **0.0.x** are built with Cats-Effect 2 from branch `master`. This is a terminal series and will end sometime in 2021. -- Versions **0.1.x** are built with Cats-Effect 3 from branch `series/0.1`. This will be the continuing series moving forward. -- Contibutions should target the `master` branch. Maintainers will merge these into `series/0.1` as needed. - +Contibutions should target the **newest active branch** (see above). Maintainers will back-port to older branches when appropriate. From 128cd8ba4f1833683a98b4561db7ff46d8459f9a Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 26 May 2021 22:16:48 +0200 Subject: [PATCH 012/178] Update circe-core to 0.14.1 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 9f954947..07ee026d 100644 --- a/build.sbt +++ b/build.sbt @@ -248,7 +248,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.0", + "io.circe" %%% "circe-core" % "0.14.1", "org.typelevel" %%% "log4cats-core" % "2.1.1", "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, ) @@ -270,7 +270,7 @@ lazy val newrelic = project name := "newrelic", description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.14.0", + "io.circe" %% "circe-core" % "0.14.1", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.12.0", From 41f6f4374fa7208c88928db20de9dfdca7a6c674 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 27 May 2021 02:30:23 +0200 Subject: [PATCH 013/178] Update refined to 0.9.26 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 07ee026d..7f42872f 100644 --- a/build.sbt +++ b/build.sbt @@ -336,7 +336,7 @@ lazy val examples = project libraryDependencies ++= Seq( "org.typelevel" %% "log4cats-slf4j" % "2.1.1", "org.slf4j" % "slf4j-simple" % "1.7.30", - "eu.timepit" %% "refined" % "0.9.25", + "eu.timepit" %% "refined" % "0.9.26", "is.cir" %% "ciris" % "2.0.0" ) ) From 8f6daccf7810360ea405703e3790a8e48753a2a3 Mon Sep 17 00:00:00 2001 From: Michael Pilquist Date: Fri, 28 May 2021 11:45:14 -0400 Subject: [PATCH 014/178] Add utilities for converting Kleisli[F, Span[F], A] to F[A] --- modules/core/shared/src/main/scala/Span.scala | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/modules/core/shared/src/main/scala/Span.scala b/modules/core/shared/src/main/scala/Span.scala index 32b12849..d213b002 100644 --- a/modules/core/shared/src/main/scala/Span.scala +++ b/modules/core/shared/src/main/scala/Span.scala @@ -4,7 +4,9 @@ package natchez -import cats.Applicative, cats.syntax.applicative._ +import cats.{~>, Applicative} +import cats.syntax.applicative._ +import cats.data.Kleisli import cats.effect.Resource import cats.effect.Resource.ExitCase import java.net.URI @@ -53,4 +55,46 @@ object Span { case ExitCase.Errored(f: Fields) => span.put(f.fields.toList: _*) case _ => Applicative[F].unit })) + + /** + * A no-op `Span` implementation which ignors all child span creation. + */ + def noop[F[_]: Applicative]: Span[F] = new NoopSpan + + /** + * A `Span` implementation which creates a new root span using the supplied `EntryPoint` + * for each requested child span. + */ + def makeRoots[F[_]: Applicative](ep: EntryPoint[F]): Span[F] = new RootsSpan(ep) + + private abstract class EphemeralSpan[F[_]: Applicative] extends Span[F] { + def put(fields: (String, TraceValue)*): F[Unit] = ().pure[F] + def kernel: F[Kernel] = Kernel(Map.empty).pure[F] + def traceId: F[Option[String]] = (None: Option[String]).pure[F] + def spanId: F[Option[String]] = (None: Option[String]).pure[F] + def traceUri: F[Option[URI]] = (None: Option[URI]).pure[F] + } + + private class NoopSpan[F[_]: Applicative] extends EphemeralSpan[F] { + def span(name: String): Resource[F, Span[F]] = Resource.pure(this) + } + + private class RootsSpan[F[_]: Applicative](ep: EntryPoint[F]) extends EphemeralSpan[F] { + def span(name: String): Resource[F, Span[F]] = ep.root(name) + } + + private def resolve[F[_]](span: Span[F]): Kleisli[F, Span[F], *] ~> F = + new (Kleisli[F, Span[F], *] ~> F) { + def apply[A](k: Kleisli[F, Span[F], A]) = k(span) + } + + /** + * Resolves a `Kleisli[F, Span[F], A]` to a `F[A]` by ignoring all span creation. + */ + def dropTracing[F[_]: Applicative]: Kleisli[F, Span[F], *] ~> F = resolve(noop) + + /** + * Resolves a `Kleisli[F, Span[F], A]` to a `F[A]` by creating a new root span for each direct child span. + */ + def rootTracing[F[_]: Applicative](ep: EntryPoint[F]): Kleisli[F, Span[F], *] ~> F = resolve(makeRoots(ep)) } From c4f061312640fcc734cc6a7d7bc90a9251563f8d Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 29 May 2021 14:56:52 +0200 Subject: [PATCH 015/178] Update ciris to 2.0.1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 7f42872f..fdbca4ec 100644 --- a/build.sbt +++ b/build.sbt @@ -337,7 +337,7 @@ lazy val examples = project "org.typelevel" %% "log4cats-slf4j" % "2.1.1", "org.slf4j" % "slf4j-simple" % "1.7.30", "eu.timepit" %% "refined" % "0.9.26", - "is.cir" %% "ciris" % "2.0.0" + "is.cir" %% "ciris" % "2.0.1" ) ) From 66d7819eb8209997b26f0a856a9946a51ab55c7c Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 1 Jun 2021 09:39:58 +0200 Subject: [PATCH 016/178] Update sbt to 1.5.3 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 19479ba4..67d27a1d 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.2 +sbt.version=1.5.3 From e350bc6b1bf2d56bf167c18bb4d9283be4aed623 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 1 Jun 2021 17:08:07 +0200 Subject: [PATCH 017/178] Update sbt-tpolecat to 0.1.20 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 0d7c36dd..2dce6e50 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,7 +3,7 @@ addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.18") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") From b6f8bcc21ae68bbd8471e4a84e85833ddba71bbb Mon Sep 17 00:00:00 2001 From: Andi Miller Date: Fri, 11 Jun 2021 15:06:31 +0100 Subject: [PATCH 018/178] Add an `opentelemetry` module This adds a `natchez-opentelemetry` module which allows span reporting via the `opentelemetry-java` project. The `Utils` object contains a helper to turn the `OpenTelemetry` `CompletableResultCode` class into an `F[Unit]` given `Async[F]`, this is useful for implementing `Resource`s for clean shutdown logic. `Shutdownable` is a little abstraction to unify all the interfaces that have a `shutdown(): CompletableResultCode` method in `OpenTelemetry`, since they have no common interface. `OpenTelemetrySpan` and `OpenTelemetryEntryPoint` are heavily based on the `natchez-jaeger` versions, with tweaks to make them with with `OpenTelemetry. The `OpenTelemetry` object which end users should interact with has these methods: * `lift` can be used to lift any `F[T]` where `T` is an `OpenTelemetry` class with a `shutdown` method into a `Resource[F, T], it asks for a name to provide a nice error message * `entryPoint` is the main way to make an `EntryPoint` and has a boolean flag to allow the user to globally register the `OpenTelemetry` if that's helpful, this defaults to false. * `globalEntryPoint` will use the globally registered `OpenTelemetry` to create an `EntryPoint` Note that this is currently using `OpenTelemetry` libraries at `1.4.0-SNAPSHOT` because I found a bug while developing this this broke the shutdown logic. The issue is here https://github.com/open-telemetry/opentelemetry-java/issues/3306 and it was closed by this PR https://github.com/open-telemetry/opentelemetry-java/pull/3307 so it should make it into the next release. --- build.sbt | 38 ++++++-- .../docs/src/main/paradox/backends/index.md | 1 + .../main/paradox/backends/opentelemetry.md | 89 +++++++++++++++++++ .../main/scala-2/OpenTelemetryExample.scala | 79 ++++++++++++++++ .../natchez/opentelemetry/OpenTelemetry.scala | 60 +++++++++++++ .../OpenTelemetryEntryPoint.scala | 50 +++++++++++ .../opentelemetry/OpenTelemetrySpan.scala | 83 +++++++++++++++++ .../natchez/opentelemetry/Shutdownable.scala | 20 +++++ .../scala/natchez/opentelemetry/Utils.scala | 29 ++++++ 9 files changed, 440 insertions(+), 9 deletions(-) create mode 100644 modules/docs/src/main/paradox/backends/opentelemetry.md create mode 100644 modules/examples/src/main/scala-2/OpenTelemetryExample.scala create mode 100644 modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetry.scala create mode 100644 modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetryEntryPoint.scala create mode 100644 modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetrySpan.scala create mode 100644 modules/opentelemetry/src/main/scala/natchez/opentelemetry/Shutdownable.scala create mode 100644 modules/opentelemetry/src/main/scala/natchez/opentelemetry/Utils.scala diff --git a/build.sbt b/build.sbt index 04f79c00..19151847 100644 --- a/build.sbt +++ b/build.sbt @@ -67,6 +67,8 @@ lazy val commonSettings = Seq( compilerPlugin("org.typelevel" %% "kind-projector" % "0.11.3" cross CrossVersion.full), ).filterNot(_ => scalaVersion.value.startsWith("3.")), + resolvers += Resolver.sonatypeRepo("snapshots"), // until opentelemetry release 1.4.0 or 1.3.1 + // dottydoc really doesn't work at all right now Compile / doc / sources := { val old = (Compile / doc / sources).value @@ -100,8 +102,8 @@ lazy val natchez = project crossScalaVersions := Nil, publish / skip := true ) - .dependsOn(coreJS, coreJVM, jaeger, honeycomb, opencensus, opentracing, datadog, lightstep, lightstepGrpc, lightstepHttp, logJS, logJVM, mtlJS, mtlJVM, noop, mock, newrelic, logOdin, examples) - .aggregate(coreJS, coreJVM, jaeger, honeycomb, opencensus, opentracing, datadog, lightstep, lightstepGrpc, lightstepHttp, logJS, logJVM, mtlJS, mtlJVM, noop, mock, newrelic, logOdin, examples) + .dependsOn(coreJS, coreJVM, jaeger, honeycomb, opencensus, opentracing, datadog, lightstep, lightstepGrpc, lightstepHttp, logJS, logJVM, mtlJS, mtlJVM, noop, mock, newrelic, opentelemetry, logOdin, examples) + .aggregate(coreJS, coreJVM, jaeger, honeycomb, opencensus, opentracing, datadog, lightstep, lightstepGrpc, lightstepHttp, logJS, logJVM, mtlJS, mtlJVM, noop, mock, newrelic, opentelemetry, logOdin, examples) lazy val core = crossProject(JSPlatform, JVMPlatform) .in(file("modules/core")) @@ -278,6 +280,21 @@ lazy val newrelic = project ) ) +lazy val opentelemetry = project + .in(file("modules/opentelemetry")) + .dependsOn(coreJVM) + .enablePlugins(AutomateHeaderPlugin) + .settings(commonSettings) + .settings( + name := "opentelemetry", + description := "OpenTelemetry bindings for Natchez.", + libraryDependencies ++= Seq( + "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, + "io.opentelemetry" % "opentelemetry-api" % "1.4.0-SNAPSHOT", + "io.opentelemetry" % "opentelemetry-sdk" % "1.4.0-SNAPSHOT", + ) + ) + lazy val mtl = crossProject(JSPlatform, JVMPlatform) .in(file("modules/mtl")) .enablePlugins(AutomateHeaderPlugin) @@ -325,7 +342,7 @@ lazy val mock = project lazy val examples = project .in(file("modules/examples")) - .dependsOn(coreJVM, jaeger, honeycomb, lightstepHttp, datadog, logJVM, newrelic, logOdin) + .dependsOn(coreJVM, jaeger, honeycomb, lightstepHttp, datadog, logJVM, newrelic, logOdin, opentelemetry) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( @@ -334,11 +351,13 @@ lazy val examples = project description := "Example programs for Natchez.", scalacOptions -= "-Xfatal-warnings", libraryDependencies ++= Seq( - "org.typelevel" %% "log4cats-slf4j" % "1.3.1", - "org.slf4j" % "slf4j-simple" % "1.7.30", - "eu.timepit" %% "refined" % "0.9.25", - "is.cir" %% "ciris" % "1.2.1" - ).filterNot(_ => scalaVersion.value.startsWith("3.")) + "org.typelevel" %% "log4cats-slf4j" % "1.3.1", + "org.slf4j" % "slf4j-simple" % "1.7.30", + "eu.timepit" %% "refined" % "0.9.25", + "is.cir" %% "ciris" % "1.2.1", + "io.opentelemetry" % "opentelemetry-exporter-otlp" % "1.4.0-SNAPSHOT", + "io.grpc" % "grpc-okhttp" % "1.38.0", // required for the OpenTelemetry exporter +).filterNot(_ => scalaVersion.value.startsWith("3.")) ) lazy val logOdin = project @@ -359,7 +378,7 @@ lazy val logOdin = project lazy val docs = project .in(file("modules/docs")) - .dependsOn(mtlJVM, honeycomb, jaeger, logJVM) + .dependsOn(mtlJVM, honeycomb, jaeger, logJVM, opentelemetry) .enablePlugins(AutomateHeaderPlugin) .enablePlugins(ParadoxPlugin) .enablePlugins(ParadoxSitePlugin) @@ -390,6 +409,7 @@ lazy val docs = project "org.http4s" %% "http4s-client" % "0.21.15", "org.typelevel" %% "log4cats-slf4j" % "1.3.1", "org.slf4j" % "slf4j-simple" % "1.7.30", + "io.opentelemetry" % "opentelemetry-exporter-otlp" % "1.4.0-SNAPSHOT", // for the opentelemetry example ) ) diff --git a/modules/docs/src/main/paradox/backends/index.md b/modules/docs/src/main/paradox/backends/index.md index 3a01e850..54664851 100644 --- a/modules/docs/src/main/paradox/backends/index.md +++ b/modules/docs/src/main/paradox/backends/index.md @@ -14,6 +14,7 @@ Natchez supports the following tracing back ends. If you're not sure which one y * [No-Op](noop.md) * [Odin](odin.md) * [OpenCensus](opencensus.md) +* [OpenTelemetry](opentelemetry.md) @@@ diff --git a/modules/docs/src/main/paradox/backends/opentelemetry.md b/modules/docs/src/main/paradox/backends/opentelemetry.md new file mode 100644 index 00000000..b56aaf6d --- /dev/null +++ b/modules/docs/src/main/paradox/backends/opentelemetry.md @@ -0,0 +1,89 @@ +# OpenTelemetry + +The `natchez-opentelemetry` module provides a backend that uses [OpenTelemetry](https://opentelemetry.io) to report spans. + +To use it, add the following dependency. + +@@dependency[sbt,Maven,Gradle] { +group="$org$" +artifact="natchez-opentelemetry-2.13" +version="$version$" +} + +Then add any exporter, for example: + +@@dependency[sbt,Maven,Gradle] { +group="io.opentelemetry" +artifact="opentelemetry-exporter-otlp" +version="1.4.0-SNAPSHOT" +} + +## Note on the OpenTelemetry version numbers + +Currently, this depends on `1.4.0-SNAPSHOT` because of a bug I discovered upstream while writing this, where the `shutdown()` calls could block indefinitely, this has been fixed in the snapshot build, and this note can be removed once there's a stable release with this fix. + +## Configuring an OpenTelemetry entrypoint + +There are two methods you'll need to construct an `OpenTelemetry` `EndPoint`. + +`OpenTelemetry.lift` is used to turn an `F[_]` that constructs a `SpanExporter`, `SpanProcessor` or `SdkTraceProvider` into a `Resource` that will shut it down cleanly. +This takes a `String` of what you've constructed, so we can give a nice error if it fails to shut down cleanly. + +The `OpenTelemetry.entryPoint` method takes a boolean called `globallyRegister` which tells it whether to register this `OpenTelemetrySdk` globally, this may be helpful if you have other java dependencies that use the global tracer, it defaults to false. +It also takes an `OpenTelemetrySdkBuilder => Resource[F, OpenTelemetrySdkBuilder]` so that you can configure the Sdk. + +Here's an example of configuring one with the `otlp` exporter with batch span processing: + +```scala mdoc:passthrough +import natchez.EntryPoint +import natchez.opentelemetry.OpenTelemetry +import cats.effect._ +import io.opentelemetry.api.common.Attributes +import io.opentelemetry.semconv.resource.attributes.ResourceAttributes +import io.opentelemetry.sdk.resources.{Resource => OtelResource} +import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator +import io.opentelemetry.context.propagation.ContextPropagators +import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter +import io.opentelemetry.sdk.trace.SdkTracerProvider +import io.opentelemetry.sdk.trace.`export`.BatchSpanProcessor + + def entryPoint[F[_]: Async]: Resource[F, EntryPoint[F]] = + for { + exporter <- OpenTelemetry.lift( + "OtlpGrpcSpanExporter", + Sync[F].delay { + OtlpGrpcSpanExporter.builder() + .setEndpoint("http://localhost:4317") + .build() + } + ) + processor <- OpenTelemetry.lift( + "BatchSpanProcessor", + Sync[F].delay { + BatchSpanProcessor.builder(exporter).build() + } + ) + tracer <- OpenTelemetry.lift( + "Tracer", + Sync[F].delay { + SdkTracerProvider.builder() + .setResource( + OtelResource.create( + Attributes.of(ResourceAttributes.SERVICE_NAME, "OpenTelemetryExample") + ) + ) + .addSpanProcessor(processor) + .build() + } + ) + ep <- OpenTelemetry.entryPoint(globallyRegister = true) { builder => + Resource.eval(Sync[F].delay { + builder + .setTracerProvider(tracer) + .setPropagators( + ContextPropagators.create(W3CTraceContextPropagator.getInstance()) + ) + } + )} + } yield ep +``` \ No newline at end of file diff --git a/modules/examples/src/main/scala-2/OpenTelemetryExample.scala b/modules/examples/src/main/scala-2/OpenTelemetryExample.scala new file mode 100644 index 00000000..59e987a8 --- /dev/null +++ b/modules/examples/src/main/scala-2/OpenTelemetryExample.scala @@ -0,0 +1,79 @@ +import cats.data.Kleisli +import cats.effect._ +import cats.implicits._ +import io.opentelemetry.api.common.Attributes +import io.opentelemetry.sdk.resources.{Resource => OtelResource} +import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator +import io.opentelemetry.context.propagation.ContextPropagators +import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter +import io.opentelemetry.sdk.trace.SdkTracerProvider +import io.opentelemetry.sdk.trace.`export`.BatchSpanProcessor +import io.opentelemetry.semconv.resource.attributes.ResourceAttributes +import natchez.{EntryPoint, Span, Trace} +import natchez.opentelemetry.OpenTelemetry + +import java.util.concurrent.TimeUnit +import scala.concurrent.duration.DurationInt + +// change this into an object if you'd like to run it +object OpenTelemetryExample extends IOApp { + def entryPoint[F[_]: Async]: Resource[F, EntryPoint[F]] = + for { + exporter <- OpenTelemetry.lift( + "OtlpGrpcSpanExporter", + Sync[F].delay { + OtlpGrpcSpanExporter.builder() + .setEndpoint("http://localhost:4317") + .build() + } + ) + processor <- OpenTelemetry.lift( + "BatchSpanProcessor", + Sync[F].delay { + BatchSpanProcessor.builder(exporter).build() + } + ) + tracer <- OpenTelemetry.lift( + "Tracer", + Sync[F].delay { + SdkTracerProvider.builder() + .setResource( + OtelResource.create( + Attributes.of(ResourceAttributes.SERVICE_NAME, "OpenTelemetryExample") + ) + ) + .addSpanProcessor(processor) + .build() + } + ) + ep <- OpenTelemetry.entryPoint(globallyRegister = true) { builder => + Resource.eval(Sync[F].delay { + builder + .setTracerProvider(tracer) + .setPropagators( + ContextPropagators.create(W3CTraceContextPropagator.getInstance()) + ) + } + )} + } yield ep + + override def run(args: List[String]): IO[ExitCode] = + entryPoint[IO].use { ep => + ep.root("root span").use { span => + span.put("service.name" -> "natchez opentelemetry example") *> + program[Kleisli[IO, Span[IO], *]].apply(span).as(ExitCode.Success) + } + } + + def program[F[_]: Sync: Trace: Timer]: F[Unit] = + Trace[F].traceId.flatTap(tid => Sync[F].delay { println(s"did some work with traceid of $tid") }) *> + Trace[F].span("outer span") { + Trace[F].put("foo" -> "bar") *> + (Trace[F].span("first thing") { + Timer[F].sleep(2.seconds) + }, + Trace[F].span("second thing") { + Timer[F].sleep(2.seconds) + }).tupled + }.void +} diff --git a/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetry.scala b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetry.scala new file mode 100644 index 00000000..22f56503 --- /dev/null +++ b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetry.scala @@ -0,0 +1,60 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez +package opentelemetry + +import cats.effect._ +import cats.implicits._ +import io.opentelemetry.api.GlobalOpenTelemetry +import io.opentelemetry.api.trace.Tracer +import io.opentelemetry.sdk.{OpenTelemetrySdk, OpenTelemetrySdkBuilder} + +import java.net.URI + +object OpenTelemetry { + private final val instrumentationName = "natchez.opentelemetry" + + // Helper methods to help you construct Otel resources that clean themselves up + // We need a name so the failure error can contain something useful + def lift[F[_]: Async, T: Shutdownable](name: String, create: F[T]): Resource[F, T] = + Resource.make(create) { t => + Sync[F].delay { Shutdownable[T].shutdown(t) } + .flatMap(Utils.asyncFromCompletableResultCode(s"$name cleanup", _)) + } + + def entryPoint[F[_] : Sync](uriPrefix: Option[URI] = None, globallyRegister: Boolean = false)( + configure: OpenTelemetrySdkBuilder => Resource[F, OpenTelemetrySdkBuilder] + ): Resource[F, EntryPoint[F]] = { + val register: OpenTelemetrySdkBuilder => Resource[F, (OpenTelemetrySdk, Tracer)] = { b => + Resource.make( + Sync[F].delay { + val sdk = if (globallyRegister) + b.buildAndRegisterGlobal() + else + b.build() + val tracer = sdk.getTracer(instrumentationName) + (sdk, tracer) + } + ) { case (_, _) => + Sync[F].delay { + if (globallyRegister) + GlobalOpenTelemetry.resetForTest() // this seems to be the only way to deregister it + } + } + } + Resource.eval(Sync[F].delay { OpenTelemetrySdk.builder() }) + .flatMap(configure) + .flatMap(register) + .map { case (sdk, tracer) => + OpenTelemetryEntryPoint(sdk, tracer, uriPrefix) + } + } + + def globalEntryPoint[F[_]: Sync](uriPrefix: Option[URI] = None): F[OpenTelemetryEntryPoint[F]] = + Sync[F].delay { + val ot = GlobalOpenTelemetry.get() + OpenTelemetryEntryPoint(ot, ot.getTracer(instrumentationName), uriPrefix) + } +} diff --git a/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetryEntryPoint.scala b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetryEntryPoint.scala new file mode 100644 index 00000000..411f63e7 --- /dev/null +++ b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetryEntryPoint.scala @@ -0,0 +1,50 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez +package opentelemetry + +import cats.effect.{Resource, Sync} +import io.opentelemetry.api.{OpenTelemetry => OtelOpenTelemetry} +import io.opentelemetry.api.trace.{Span => OtelSpan, Tracer => OtelTracer} +import io.opentelemetry.context.Context +import io.opentelemetry.context.propagation.TextMapGetter + +import java.lang +import java.net.URI +import scala.jdk.CollectionConverters._ + +final case class OpenTelemetryEntryPoint[F[_]: Sync](sdk: OtelOpenTelemetry, tracer: OtelTracer, uriPrefix: Option[URI]) extends EntryPoint[F] { + override def root(name: String): Resource[F, Span[F]] = + Resource.make[F, OtelSpan] ( + Sync[F].delay { tracer.spanBuilder(name).startSpan() } + ) { s => + Sync[F].delay { s.end() } + }.map { span => + OpenTelemetrySpan(sdk, tracer, span, uriPrefix) + } + + object MapGetter extends TextMapGetter[Map[String, String]] { + override def keys(carrier: Map[String, String]): lang.Iterable[String] = carrier.keys.asJava + override def get(carrier: Map[String, String], key: String): String = carrier.get(key).orNull + } + + override def continue(name: String, kernel: Kernel): Resource[F, Span[F]] = + Resource.make( + Sync[F].delay { + val c = Context.root() + val p = sdk.getPropagators.getTextMapPropagator.extract( + c, + kernel.toHeaders, + MapGetter + ) + tracer.spanBuilder(name).setParent(p).startSpan() + } + ) { s => + Sync[F].delay { s.end() } + }.map(OpenTelemetrySpan(sdk, tracer, _, uriPrefix)) + + override def continueOrElseRoot(name: String, kernel: Kernel): Resource[F, Span[F]] = + continue(name, kernel) // this is already the behaviour of `continue` since it defaults to not changing the context +} diff --git a/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetrySpan.scala b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetrySpan.scala new file mode 100644 index 00000000..88772fae --- /dev/null +++ b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetrySpan.scala @@ -0,0 +1,83 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez +package opentelemetry + +import cats.data.Nested +import io.opentelemetry.api.trace.{Span => OtelSpan, Tracer => OtelTracer} +import cats.effect._ +import cats.implicits._ +import io.opentelemetry.api.{OpenTelemetry => OtelOpenTelemetry} +import io.opentelemetry.context.Context +import io.opentelemetry.context.propagation.TextMapSetter +import natchez.TraceValue._ + +import scala.collection.mutable +import java.net.URI + +final case class OpenTelemetrySpan[F[_] : Sync](sdk: OtelOpenTelemetry, tracer: OtelTracer, span: OtelSpan, prefix: Option[URI]) extends Span[F] { + override def put(fields: (String, TraceValue)*): F[Unit] = + fields.toList.traverse_ { + case (k, StringValue(v)) => Sync[F].delay(span.setAttribute(k, v)) + // all integer types are cast up to Long, since that's all OpenTelemetry lets us use + case (k, NumberValue(n: java.lang.Byte)) => Sync[F].delay(span.setAttribute(k, n.toLong)) + case (k, NumberValue(n: java.lang.Short)) => Sync[F].delay(span.setAttribute(k, n.toLong)) + case (k, NumberValue(n: java.lang.Integer)) => Sync[F].delay(span.setAttribute(k, n.toLong)) + case (k, NumberValue(n: java.lang.Long)) => Sync[F].delay(span.setAttribute(k, n)) + // and all float types are changed to Double + case (k, NumberValue(n: java.lang.Float)) => Sync[F].delay(span.setAttribute(k, n.toDouble)) + case (k, NumberValue(n: java.lang.Double)) => Sync[F].delay(span.setAttribute(k, n)) + // anything which could be too big to put in a Long is converted to a String + case (k, NumberValue(n: java.math.BigDecimal)) => Sync[F].delay(span.setAttribute(k, n.toString)) + case (k, NumberValue(n: java.math.BigInteger)) => Sync[F].delay(span.setAttribute(k, n.toString)) + case (k, NumberValue(n: BigDecimal)) => Sync[F].delay(span.setAttribute(k, n.toString)) + case (k, NumberValue(n: BigInt)) => Sync[F].delay(span.setAttribute(k, n.toString)) + // and any other Number can fall back to a Double + case (k, NumberValue(v)) => Sync[F].delay(span.setAttribute(k, v.doubleValue())) + case (k, BooleanValue(v)) => Sync[F].delay(span.setAttribute(k, v)) + } + + object MutableMapKeySetter extends TextMapSetter[mutable.HashMap[String, String]] { + override def set(carrier: mutable.HashMap[String, String], key: String, value: String): Unit = + carrier.put(key, value): Unit + } + + override def kernel: F[Kernel] = Sync[F].delay { + val m = new mutable.HashMap[String, String] + sdk.getPropagators.getTextMapPropagator.inject( + Context.current.`with`(span), + m, + MutableMapKeySetter + ) + Kernel(m.toMap) + } + + override def span(name: String): Resource[F, Span[F]] = + Span.putErrorFields( + Resource.make[F, OtelSpan]( + Sync[F].delay { + tracer.spanBuilder(name).setParent(Context.current().`with`(span)).startSpan() + }) { s => + Sync[F].delay { + s.end() + } + }.map(OpenTelemetrySpan(sdk, tracer, _, prefix)) + ) + + override def traceId: F[Option[String]] = Sync[F].delay { + val rawId = span.getSpanContext.getTraceId + if (rawId.nonEmpty) rawId.some else none + } + + override def spanId: F[Option[String]] = Sync[F].delay { + val rawId = span.getSpanContext.getSpanId + if (rawId.nonEmpty) rawId.some else none + } + + override def traceUri: F[Option[URI]] = + (Nested(prefix.pure[F]), Nested(traceId)).mapN { (uri, id) => + uri.resolve(s"/trace/$id") + }.value +} diff --git a/modules/opentelemetry/src/main/scala/natchez/opentelemetry/Shutdownable.scala b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/Shutdownable.scala new file mode 100644 index 00000000..cd57bb90 --- /dev/null +++ b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/Shutdownable.scala @@ -0,0 +1,20 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez.opentelemetry + +import io.opentelemetry.sdk.common.CompletableResultCode +import io.opentelemetry.sdk.trace.{SdkTracerProvider, SpanProcessor} +import io.opentelemetry.sdk.trace.`export`.SpanExporter + +// abstracts over all the ways Otel classes can be shut down, they don't have a common interface so let's make one +trait Shutdownable[-T] { + def shutdown(t: T): CompletableResultCode +} +object Shutdownable { + def apply[T: Shutdownable]: Shutdownable[T] = implicitly + implicit val spanExporter: Shutdownable[SpanExporter] = (t: SpanExporter) => t.shutdown() + implicit val spanProcessor: Shutdownable[SpanProcessor] = (t: SpanProcessor) => t.shutdown() + implicit val tracer: Shutdownable[SdkTracerProvider] = (t: SdkTracerProvider) => t.shutdown() +} \ No newline at end of file diff --git a/modules/opentelemetry/src/main/scala/natchez/opentelemetry/Utils.scala b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/Utils.scala new file mode 100644 index 00000000..05fbc60b --- /dev/null +++ b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/Utils.scala @@ -0,0 +1,29 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez.opentelemetry + +import cats.effect.{Async, Sync} +import cats.implicits._ +import io.opentelemetry.sdk.common.CompletableResultCode + +object Utils { + case class CompletableResultCodeFailure(s: String) extends RuntimeException(s) + + // Converts an OpenTelemetry CompletableResultCode into an Async action of return type unit + // This will raise if the action failed, but we don't get any information on the failure so we throw an empty exception + def asyncFromCompletableResultCode[F[_]: Async](name: String, crc: CompletableResultCode): F[Unit] = { + Async[F].asyncF[Unit] { cb => + Sync[F].delay { + crc.whenComplete( + () => if (crc.isSuccess) { + cb(().asRight) + } else { + cb(CompletableResultCodeFailure(s"The OpenTelemetry action '$name' failed").asLeft) + } + ): Unit + } + } + } +} From 446cf1c3c59dc676d4a8b832fcbf165fd25c2a39 Mon Sep 17 00:00:00 2001 From: Andi Miller Date: Fri, 11 Jun 2021 15:22:57 +0100 Subject: [PATCH 019/178] Swap OpenTelemetryExample to a class so it's not the default example --- modules/examples/src/main/scala-2/OpenTelemetryExample.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/examples/src/main/scala-2/OpenTelemetryExample.scala b/modules/examples/src/main/scala-2/OpenTelemetryExample.scala index 59e987a8..c71bd160 100644 --- a/modules/examples/src/main/scala-2/OpenTelemetryExample.scala +++ b/modules/examples/src/main/scala-2/OpenTelemetryExample.scala @@ -16,7 +16,7 @@ import java.util.concurrent.TimeUnit import scala.concurrent.duration.DurationInt // change this into an object if you'd like to run it -object OpenTelemetryExample extends IOApp { +class OpenTelemetryExample extends IOApp { def entryPoint[F[_]: Async]: Resource[F, EntryPoint[F]] = for { exporter <- OpenTelemetry.lift( From 00fe0f91a39004671c3eabd4e4e610399295638f Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 14 Jun 2021 09:25:44 +0200 Subject: [PATCH 020/178] Update sbt to 1.5.4 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 67d27a1d..9edb75b7 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.3 +sbt.version=1.5.4 From 7d3ba3d3dc27154f94032a3d7b54d1018c3c1403 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 18 Jun 2021 02:36:35 +0200 Subject: [PATCH 021/178] Update grpc-netty to 1.38.1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index fdbca4ec..85e5472c 100644 --- a/build.sbt +++ b/build.sbt @@ -190,7 +190,7 @@ lazy val lightstepGrpc = project description := "Lightstep gRPC bindings for Natchez.", libraryDependencies ++= Seq( "com.lightstep.tracer" % "tracer-grpc" % "0.30.3", - "io.grpc" % "grpc-netty" % "1.38.0", + "io.grpc" % "grpc-netty" % "1.38.1", "io.netty" % "netty-tcnative-boringssl-static" % "2.0.39.Final" ) ) From dd4d4ed4a8bc9e74faa87f5b8a1d55918d88dfb2 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 18 Jun 2021 08:46:05 +0200 Subject: [PATCH 022/178] Update slf4j-simple to 1.7.31 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 85e5472c..52bb6a82 100644 --- a/build.sbt +++ b/build.sbt @@ -335,7 +335,7 @@ lazy val examples = project scalacOptions -= "-Xfatal-warnings", libraryDependencies ++= Seq( "org.typelevel" %% "log4cats-slf4j" % "2.1.1", - "org.slf4j" % "slf4j-simple" % "1.7.30", + "org.slf4j" % "slf4j-simple" % "1.7.31", "eu.timepit" %% "refined" % "0.9.26", "is.cir" %% "ciris" % "2.0.1" ) @@ -389,7 +389,7 @@ lazy val docs = project "org.http4s" %% "http4s-dsl" % "0.23.0-M1", "org.http4s" %% "http4s-client" % "0.23.0-M1", "org.typelevel" %% "log4cats-slf4j" % "2.1.1", - "org.slf4j" % "slf4j-simple" % "1.7.30", + "org.slf4j" % "slf4j-simple" % "1.7.31", ) ) From dc9a2d270cedd17ab348fad6a0ac615d499c5fee Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 3 Jul 2021 05:14:22 +0200 Subject: [PATCH 023/178] Update sbt-scalajs-crossproject to 1.1.0 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 2dce6e50..8f51477d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -6,6 +6,6 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.21") From a597ad1cbcc08ea6238e82b71a9a3b572d12f4fa Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 9 Jul 2021 16:14:11 +0200 Subject: [PATCH 024/178] Update scala3-library, ... to 3.0.1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 52bb6a82..880fe161 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ val scala212Version = "2.12.12" val scala213Version = "2.13.5" -val scala30Version = "3.0.0" +val scala30Version = "3.0.1" val collectionCompatVersion = "2.4.4" From f597315adf3b12450aa565348c36b9cbb53d831f Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 20 Jul 2021 11:18:14 +0200 Subject: [PATCH 025/178] Update refined to 0.9.27 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 880fe161..c3a669dc 100644 --- a/build.sbt +++ b/build.sbt @@ -336,7 +336,7 @@ lazy val examples = project libraryDependencies ++= Seq( "org.typelevel" %% "log4cats-slf4j" % "2.1.1", "org.slf4j" % "slf4j-simple" % "1.7.31", - "eu.timepit" %% "refined" % "0.9.26", + "eu.timepit" %% "refined" % "0.9.27", "is.cir" %% "ciris" % "2.0.1" ) ) From 36165c96c9af587b163e84e84e87f5aaac45136d Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 20 Jul 2021 16:13:22 +0200 Subject: [PATCH 026/178] Update slf4j-simple to 1.7.32 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index c3a669dc..c70c632f 100644 --- a/build.sbt +++ b/build.sbt @@ -335,7 +335,7 @@ lazy val examples = project scalacOptions -= "-Xfatal-warnings", libraryDependencies ++= Seq( "org.typelevel" %% "log4cats-slf4j" % "2.1.1", - "org.slf4j" % "slf4j-simple" % "1.7.31", + "org.slf4j" % "slf4j-simple" % "1.7.32", "eu.timepit" %% "refined" % "0.9.27", "is.cir" %% "ciris" % "2.0.1" ) @@ -389,7 +389,7 @@ lazy val docs = project "org.http4s" %% "http4s-dsl" % "0.23.0-M1", "org.http4s" %% "http4s-client" % "0.23.0-M1", "org.typelevel" %% "log4cats-slf4j" % "2.1.1", - "org.slf4j" % "slf4j-simple" % "1.7.31", + "org.slf4j" % "slf4j-simple" % "1.7.32", ) ) From ee411e4d48c3f45f45dc854ae8319d5b8bde306a Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 22 Jul 2021 15:11:48 +0200 Subject: [PATCH 027/178] Update mdoc, sbt-mdoc to 2.2.22 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 2dce6e50..c0f9c49d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -8,4 +8,4 @@ addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.21") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.22") From 280dbdb183454bca7d4a3ab5af54d1fbd48639db Mon Sep 17 00:00:00 2001 From: Yannick Heiber Date: Tue, 27 Jul 2021 23:53:46 +0200 Subject: [PATCH 028/178] Bring back Odin module Odin now has a Scala 3-compatible release 0.12, so it can be re-added to natchez. Code needed one little adjustment only, due to Scala 3's tuples having a "map" method. --- build.sbt | 29 +++++++++---------- .../src/main/{scala-2 => scala}/Log.scala | 0 .../src/main/{scala-2 => scala}/LogSpan.scala | 4 +-- 3 files changed, 16 insertions(+), 17 deletions(-) rename modules/log-odin/src/main/{scala-2 => scala}/Log.scala (100%) rename modules/log-odin/src/main/{scala-2 => scala}/LogSpan.scala (99%) diff --git a/build.sbt b/build.sbt index c70c632f..dc20208e 100644 --- a/build.sbt +++ b/build.sbt @@ -341,21 +341,20 @@ lazy val examples = project ) ) -// lazy val logOdin = project -// .in(file("modules/log-odin")) -// .dependsOn(coreJVM) -// .enablePlugins(AutomateHeaderPlugin) -// .settings(commonSettings) -// .settings( -// publish / skip := scalaVersion.value.startsWith("3."), -// name := "natchez-log-odin", -// description := "Logging bindings for Natchez, using Odin.", -// libraryDependencies ++= Seq( -// "io.circe" %% "circe-core" % "0.14.0", -// "com.github.valskalla" %% "odin-core" % "0.9.1", -// "com.github.valskalla" %% "odin-json" % "0.9.1" -// ).filterNot(_ => scalaVersion.value.startsWith("3.")) -// ) +lazy val logOdin = project + .in(file("modules/log-odin")) + .dependsOn(coreJVM) + .enablePlugins(AutomateHeaderPlugin) + .settings(commonSettings) + .settings( + name := "natchez-log-odin", + description := "Logging bindings for Natchez, using Odin.", + libraryDependencies ++= Seq( + "io.circe" %% "circe-core" % "0.14.1", + "com.github.valskalla" %% "odin-core" % "0.12.0", + "com.github.valskalla" %% "odin-json" % "0.12.0" + ) + ) lazy val docs = project .in(file("modules/docs")) diff --git a/modules/log-odin/src/main/scala-2/Log.scala b/modules/log-odin/src/main/scala/Log.scala similarity index 100% rename from modules/log-odin/src/main/scala-2/Log.scala rename to modules/log-odin/src/main/scala/Log.scala diff --git a/modules/log-odin/src/main/scala-2/LogSpan.scala b/modules/log-odin/src/main/scala/LogSpan.scala similarity index 99% rename from modules/log-odin/src/main/scala-2/LogSpan.scala rename to modules/log-odin/src/main/scala/LogSpan.scala index b722d558..3b4eac65 100644 --- a/modules/log-odin/src/main/scala-2/LogSpan.scala +++ b/modules/log-odin/src/main/scala/LogSpan.scala @@ -89,7 +89,7 @@ private[logodin] final case class LogSpan[F[_]: Sync: Logger]( exitCase match { case Succeeded => List("exit.case" -> "completed".asJson) case Canceled => List("exit.case" -> "canceled".asJson) - case Errored(ex: Fields) => exitFields(ex) ++ ex.fields.toList.map(_.map(_.asJson)) + case Errored(ex: Fields) => exitFields(ex) ++ ex.fields.toList.map(_.fmap(_.asJson)) case Errored(ex) => exitFields(ex) } } ++ fs ++ List("children" -> cs.reverse.map(Json.fromJsonObject).asJson) @@ -213,4 +213,4 @@ private[logodin] object LogSpan { fromKernel(service, name, kernel).recoverWith { case _: NoSuchElementException => root(service, name) } -} \ No newline at end of file +} From 860336b62181198e0f4d7461b4bf681ae9f8a763 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 3 Aug 2021 01:05:14 +0200 Subject: [PATCH 029/178] Update sbt-updates to 0.6.0 --- project/plugins.sbt | 2 +- project/project/plugins.sbt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index c0f9c49d..f73b8c23 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -4,7 +4,7 @@ addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") diff --git a/project/project/plugins.sbt b/project/project/plugins.sbt index 2e5f8761..fbb205c7 100644 --- a/project/project/plugins.sbt +++ b/project/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.0") From c372ff20470ee60edb2f7cabed4bffb29f7c234b Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 27 Aug 2021 13:19:17 +0200 Subject: [PATCH 030/178] Update mdoc, sbt-mdoc to 2.2.23 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index c0f9c49d..0f103bd2 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -8,4 +8,4 @@ addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.22") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.23") From 2db484226a5c69aa5834eee7492b5c3eddece609 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 31 Aug 2021 13:28:17 +0200 Subject: [PATCH 031/178] Update munit to 0.7.29 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index c70c632f..6ed3dc97 100644 --- a/build.sbt +++ b/build.sbt @@ -54,7 +54,7 @@ lazy val commonSettings = Seq( // Testing libraryDependencies ++= Seq( - "org.scalameta" %%% "munit" % "0.7.26" % Test, + "org.scalameta" %%% "munit" % "0.7.29" % Test, "org.typelevel" %%% "munit-cats-effect-3" % "1.0.3" % Test, ), testFrameworks += new TestFramework("munit.Framework"), From 8526beecea11b116ca6f87190ad61816ec688238 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 1 Sep 2021 13:40:59 +0200 Subject: [PATCH 032/178] Update scala3-library, ... to 3.0.2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index c70c632f..8485364b 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ val scala212Version = "2.12.12" val scala213Version = "2.13.5" -val scala30Version = "3.0.1" +val scala30Version = "3.0.2" val collectionCompatVersion = "2.4.4" From d1cc4219d351aac8c0bce2580642c9aa0d92503c Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 4 Sep 2021 02:42:24 +0200 Subject: [PATCH 033/178] Update kind-projector to 0.13.2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 8485364b..c2b68b50 100644 --- a/build.sbt +++ b/build.sbt @@ -70,7 +70,7 @@ lazy val commonSettings = Seq( "-doc-source-url", "https://github.com/tpolecat/natchez/blob/v" + version.value + "€{FILE_PATH}.scala" ), libraryDependencies ++= Seq( - compilerPlugin("org.typelevel" %% "kind-projector" % "0.11.3" cross CrossVersion.full), + compilerPlugin("org.typelevel" %% "kind-projector" % "0.13.2" cross CrossVersion.full), ).filterNot(_ => scalaVersion.value.startsWith("3.")), // dottydoc really doesn't work at all right now From 8ac936cc2b369c2b794ebcce7c7020c0e7d155dc Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 15 Sep 2021 02:46:02 +0200 Subject: [PATCH 034/178] Update scala-library to 2.12.15 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 8485364b..98bbfc82 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -val scala212Version = "2.12.12" +val scala212Version = "2.12.15" val scala213Version = "2.13.5" val scala30Version = "3.0.2" From 378a047c33d4a6be9240c666ae80c96247bf0a04 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 22 Sep 2021 22:20:40 +0200 Subject: [PATCH 035/178] Update sbt-ci-release to 1.5.9 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 0f103bd2..158bca02 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.9") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") From 8dc63c87b629cce4e64a4866190b7b310a077f67 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 14 Oct 2021 17:13:36 +0200 Subject: [PATCH 036/178] Update sbt-ci-release to 1.5.10 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 158bca02..c755bb98 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.9") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") From b92fc427245ef367fc80e57fe674770810c9c46d Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 18 Oct 2021 15:22:32 +0200 Subject: [PATCH 037/178] Update scala3-library, ... to 3.1.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 8485364b..926fe350 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ val scala212Version = "2.12.12" val scala213Version = "2.13.5" -val scala30Version = "3.0.2" +val scala30Version = "3.1.0" val collectionCompatVersion = "2.4.4" From 26a930de676dad8040f4b9d663c208ff50917fbb Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 20 Oct 2021 17:17:32 +0200 Subject: [PATCH 038/178] Update mdoc, sbt-mdoc to 2.2.24 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index c755bb98..bfefaec4 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -8,4 +8,4 @@ addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.23") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.24") From 24072814d3f880821ae6377f90dd66190e2a1f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Wed, 20 Oct 2021 20:14:19 +0200 Subject: [PATCH 039/178] Add docs for DataDog tracer --- CONTRIBUTING.md | 5 ++ .../docs/src/main/paradox/backends/datadog.md | 46 ++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..0594203f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,5 @@ +# Contributing + +## Build the site + +`sbt docs/makeSite` diff --git a/modules/docs/src/main/paradox/backends/datadog.md b/modules/docs/src/main/paradox/backends/datadog.md index c11e557b..742d0526 100644 --- a/modules/docs/src/main/paradox/backends/datadog.md +++ b/modules/docs/src/main/paradox/backends/datadog.md @@ -1 +1,45 @@ -# Datadog \ No newline at end of file +# Datadog + +To get access to an `EntryPoint` instance for DataDog, add the following dependency. + +It transitively pulls in `"com.datadoghq" % "dd-trace-ot"` and `"com.datadoghq" % "dd-trace-api"`. + +@@dependency[sbt,Maven,Gradle] { + group="$org$" + artifact="natchez-datadog_2.13" + version="$version$" +} + +## Constructing an EntryPoint + +You can use `DDTracer.entryPoint` to build a DataDog tracer, register it globally, and get it as a `Resource[F, EntryPoint[F]]`. +The method takes a function in which you can customize the underlying `DDTracerBuilder` instance to specify the service name, sampling rules, etc. + +At the end, the function should return a `datadog.opentracing.DDTracer`, for example by calling `build()`. + +The builder is mutable, so customizing it is considered an effect - hence the wrapping in `Sync[F].delay`: + +```scala mdoc +import cats.effect.{Sync, Resource} +import natchez.datadog.DDTracer +import natchez.EntryPoint + +def entryPoint[F[_]: Sync]: Resource[F, EntryPoint[F]] = + DDTracer.entryPoint[F] { + builder => Sync[F].delay { + builder + .serviceName("my-app") + .build() + } + } +``` + +An alternative approach is to use the already registered global tracer (for example, if you've already set it up and registered through some other means, like adding the Java Agent): + +```scala mdoc +import java.net.URI + +// Will return `None` if there's no tracer registered already +def entryPointUseGlobal[F[_]: Sync]: F[Option[EntryPoint[F]]] = + DDTracer.globalTracerEntryPoint[F](Some(new URI(s"https://app.datadoghq.com"))) +``` From 032f3c6108de39747387979be3ec63f5784d8df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Wed, 20 Oct 2021 20:35:05 +0200 Subject: [PATCH 040/178] Add forgotten dependency --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 8485364b..7bb8549c 100644 --- a/build.sbt +++ b/build.sbt @@ -359,7 +359,7 @@ lazy val examples = project lazy val docs = project .in(file("modules/docs")) - .dependsOn(mtlJVM, honeycomb, jaeger, logJVM) + .dependsOn(mtlJVM, honeycomb, datadog, jaeger, logJVM) .enablePlugins(AutomateHeaderPlugin) .enablePlugins(ParadoxPlugin) .enablePlugins(ParadoxSitePlugin) From e171e4fe35449f243ddc4f617e79b185f8ca9387 Mon Sep 17 00:00:00 2001 From: Yannick Heiber Date: Thu, 21 Oct 2021 12:43:15 +0200 Subject: [PATCH 041/178] Update Odin dependency to 0.13 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index dc20208e..ac3276b3 100644 --- a/build.sbt +++ b/build.sbt @@ -351,8 +351,8 @@ lazy val logOdin = project description := "Logging bindings for Natchez, using Odin.", libraryDependencies ++= Seq( "io.circe" %% "circe-core" % "0.14.1", - "com.github.valskalla" %% "odin-core" % "0.12.0", - "com.github.valskalla" %% "odin-json" % "0.12.0" + "com.github.valskalla" %% "odin-core" % "0.13.0", + "com.github.valskalla" %% "odin-json" % "0.13.0" ) ) From 3de7cdccc09004068773caa14ee1d1b74078a2b7 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 1 Nov 2021 20:09:41 +0100 Subject: [PATCH 042/178] Update scala-library to 2.13.7 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 7bb8549c..c7f2e355 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,5 @@ val scala212Version = "2.12.12" -val scala213Version = "2.13.5" +val scala213Version = "2.13.7" val scala30Version = "3.0.2" val collectionCompatVersion = "2.4.4" From f2bf5181c17bc83798e7410a4d0602f49ffaf62f Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Tue, 2 Nov 2021 14:59:42 -0500 Subject: [PATCH 043/178] support natchez-noop on Scala.js --- build.sbt | 9 +++++++-- .../{ => shared}/src/main/scala/NoopEntrypoint.scala | 0 modules/noop/{ => shared}/src/main/scala/NoopSpan.scala | 0 modules/noop/{ => shared}/src/main/scala/NoopTrace.scala | 0 4 files changed, 7 insertions(+), 2 deletions(-) rename modules/noop/{ => shared}/src/main/scala/NoopEntrypoint.scala (100%) rename modules/noop/{ => shared}/src/main/scala/NoopSpan.scala (100%) rename modules/noop/{ => shared}/src/main/scala/NoopTrace.scala (100%) diff --git a/build.sbt b/build.sbt index 7bb8549c..389f8d9b 100644 --- a/build.sbt +++ b/build.sbt @@ -298,9 +298,9 @@ lazy val mtlJS = mtl.js.dependsOn(coreJS) scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), ) -lazy val noop = project +lazy val noop = crossProject(JSPlatform, JVMPlatform) .in(file("modules/noop")) - .dependsOn(coreJVM) + .dependsOn(core) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( @@ -308,6 +308,11 @@ lazy val noop = project description := "No-Op Open Tracing implementation", libraryDependencies ++= Seq() ) + .jsSettings( + Test / scalaJSStage := FastOptStage, + jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(), + scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), + ) lazy val mock = project .in(file("modules/mock")) diff --git a/modules/noop/src/main/scala/NoopEntrypoint.scala b/modules/noop/shared/src/main/scala/NoopEntrypoint.scala similarity index 100% rename from modules/noop/src/main/scala/NoopEntrypoint.scala rename to modules/noop/shared/src/main/scala/NoopEntrypoint.scala diff --git a/modules/noop/src/main/scala/NoopSpan.scala b/modules/noop/shared/src/main/scala/NoopSpan.scala similarity index 100% rename from modules/noop/src/main/scala/NoopSpan.scala rename to modules/noop/shared/src/main/scala/NoopSpan.scala diff --git a/modules/noop/src/main/scala/NoopTrace.scala b/modules/noop/shared/src/main/scala/NoopTrace.scala similarity index 100% rename from modules/noop/src/main/scala/NoopTrace.scala rename to modules/noop/shared/src/main/scala/NoopTrace.scala From d238a18371b3dc8862dd8af6f0c991b0ce8fe1da Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 9 Nov 2021 15:20:47 +0100 Subject: [PATCH 044/178] Update scala-collection-compat to 2.6.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 389f8d9b..86888c85 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ val scala212Version = "2.12.12" val scala213Version = "2.13.5" val scala30Version = "3.0.2" -val collectionCompatVersion = "2.4.4" +val collectionCompatVersion = "2.6.0" val catsVersion = "2.6.1" val catsEffectVersion = "3.1.1" From bccac0dcab68990e0e70912382f3c76c20c6e833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kj=C3=A6r=20Larsen?= Date: Fri, 24 Sep 2021 11:25:35 +0200 Subject: [PATCH 045/178] Added support for AWS X-Ray with an UDP socket to the X-Ray daemon --- build.sbt | 14 + modules/xray/src/main/scala/XRay.scala | 24 ++ .../xray/src/main/scala/XRayEntryPoint.scala | 41 +++ modules/xray/src/main/scala/XRaySpan.scala | 265 ++++++++++++++++++ 4 files changed, 344 insertions(+) create mode 100644 modules/xray/src/main/scala/XRay.scala create mode 100644 modules/xray/src/main/scala/XRayEntryPoint.scala create mode 100644 modules/xray/src/main/scala/XRaySpan.scala diff --git a/build.sbt b/build.sbt index 389f8d9b..1479e71d 100644 --- a/build.sbt +++ b/build.sbt @@ -314,6 +314,20 @@ lazy val noop = crossProject(JSPlatform, JVMPlatform) scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), ) +lazy val xray = project + .in(file("modules/xray")) + .dependsOn(coreJVM) + .enablePlugins(AutomateHeaderPlugin) + .settings(commonSettings) + .settings( + name := "natchez-xray", + description := "AWS X-Ray bindings implementation", + libraryDependencies ++= Seq( + "io.circe" %%% "circe-core" % "0.14.1", + "co.fs2" %%% "fs2-io" % "3.2.0" + ) + ) + lazy val mock = project .in(file("modules/mock")) .dependsOn(coreJVM) diff --git a/modules/xray/src/main/scala/XRay.scala b/modules/xray/src/main/scala/XRay.scala new file mode 100644 index 00000000..3a2a9178 --- /dev/null +++ b/modules/xray/src/main/scala/XRay.scala @@ -0,0 +1,24 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez +package xray + +import natchez.EntryPoint +import cats.effect.{Resource, Sync} +import com.comcast.ip4s._ +import fs2.io.net.Network + +object XRay { + + def entryPoint[F[_]: Sync: Network]( + daemonAddress: SocketAddress[IpAddress] = + SocketAddress(ip"127.0.0.1", port"2000") + ): Resource[F, EntryPoint[F]] = + Network[F] + .openDatagramSocket() + .map { socket => + new XRayEntryPoint[F](socket, daemonAddress) + } +} diff --git a/modules/xray/src/main/scala/XRayEntryPoint.scala b/modules/xray/src/main/scala/XRayEntryPoint.scala new file mode 100644 index 00000000..f943902d --- /dev/null +++ b/modules/xray/src/main/scala/XRayEntryPoint.scala @@ -0,0 +1,41 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez +package xray + +import cats.effect._ +import cats.syntax.all._ +import io.circe._ +import io.circe.syntax._ +import com.comcast.ip4s._ +import fs2.io.net.{DatagramSocket, Datagram} + +final class XRayEntryPoint[F[_]: Sync]( + socket: DatagramSocket[F], + daemonAddress: SocketAddress[IpAddress] +) extends EntryPoint[F] { + + def sendSegment(foo: JsonObject): F[Unit] = { + val payload = (XRayEntryPoint.header + foo.asJson.noSpaces).getBytes() + val datagram = Datagram(daemonAddress, fs2.Chunk.array(payload)) + socket.write(datagram) + } + + def make(span: F[XRaySpan[F]]): Resource[F, Span[F]] = + Resource.makeCase(span)(XRaySpan.finish(_, this, _)).widen + + def root(name: String): Resource[F, Span[F]] = + make(XRaySpan.root(name, this)) + + def continue(name: String, kernel: Kernel): Resource[F, Span[F]] = + make(XRaySpan.fromKernel(name, kernel, this)) + + def continueOrElseRoot(name: String, kernel: Kernel): Resource[F, Span[F]] = + make(XRaySpan.fromKernelOrElseRoot(name, kernel, this)) +} + +object XRayEntryPoint { + val header = "{\"format\": \"json\", \"version\": 1}\n" +} diff --git a/modules/xray/src/main/scala/XRaySpan.scala b/modules/xray/src/main/scala/XRaySpan.scala new file mode 100644 index 00000000..5de2ae90 --- /dev/null +++ b/modules/xray/src/main/scala/XRaySpan.scala @@ -0,0 +1,265 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez.xray + +import cats.effect._ +import cats.syntax.all._ +import cats.effect.Resource.ExitCase + +import natchez._ +import natchez.TraceValue._ +import cats.effect.Resource +import java.net.URI +import java.time.Instant +import io.circe.JsonObject +import cats.effect.std.Random +import io.circe._ +import io.circe.syntax._ +import cats.effect.kernel.Resource.ExitCase.Canceled +import cats.effect.kernel.Resource.ExitCase.Errored +import cats.effect.kernel.Resource.ExitCase.Succeeded + +private[xray] final case class XRaySpan[F[_]: Sync]( + entry: XRayEntryPoint[F], + name: String, + segmentId: String, + xrayTraceId: String, + parent: Option[Either[String, XRaySpan[F]]], + startTime: Instant, + fields: Ref[F, Map[String, Json]], + children: Ref[F, List[JsonObject]], + sampled: Boolean +) extends Span[F] { + import XRaySpan._ + + def put(fields: (String, TraceValue)*): F[Unit] = { + val fieldsToAdd = fields.map { case (k, v) => (k -> v.asJson) } + this.fields.update(_ ++ fieldsToAdd.toMap) + } + + def kernel: F[Kernel] = + Kernel(Map(XRaySpan.Header -> header)).pure[F] + + def span(name: String): Resource[F, Span[F]] = + Resource.makeCase(XRaySpan.child(this, name))( + XRaySpan.finish[F](_, entry, _) + ) + + def traceId: F[Option[String]] = xrayTraceId.some.pure[F] + + def spanId: F[Option[String]] = segmentId.some.pure[F] + + def traceUri: F[Option[URI]] = Option.empty.pure[F] + + private def toEpoch(t: Instant): Double = + t.getEpochSecond().toDouble + t.getNano().toDouble / 1000000000 + + def serialize(end: Instant, exitCase: ExitCase): F[JsonObject] = + (fields.get, children.get, XRaySpan.segmentId).mapN { (fs, cs, id) => + def exitFields(ex: Throwable): List[(String, Json)] = List( + "fault" -> true.asJson, + "cause" -> Json.obj( + "exceptions" -> Json.arr( + Json.obj( + "id" -> id.asJson, + "message" -> ex.getMessage().asJson, + "type" -> ex.getClass().getName().asJson, + "stack" -> ex + .getStackTrace() + .map(x => + Json.obj( + "line" -> x.getLineNumber().asJson, + "path" -> x.getFileName().asJson, + "label" -> x.getMethodName().asJson + ) + ) + .asJson + ) + ) + ) + ) + + val fields: List[(String, Json)] = + List( + "name" -> name.asJson, + "id" -> segmentId.asJson, + "start_time" -> toEpoch(startTime).asJson, + "end_time" -> toEpoch(end).asJson, + "trace_id" -> xrayTraceId.asJson, + "subsegments" -> cs.reverse.map(Json.fromJsonObject).asJson, + "annotations" -> fs.asJson + ) ++ { + exitCase match { + case Canceled => List("fault" -> true.asJson) + case Errored(e) => exitFields(e) + case Succeeded => List() + } + } + + JsonObject.fromIterable(fields) + } + + private def header: String = + s"Root=$xrayTraceId;Parent=$segmentId;Sampled=${if (sampled) "1" else "0"}" + +} + +private[xray] object XRaySpan { + + implicit val EncodeTraceValue: Encoder[TraceValue] = + Encoder.instance { + case StringValue(s) => s.asJson + case BooleanValue(b) => b.asJson + case NumberValue(n: java.lang.Byte) => n.asJson + case NumberValue(n: java.lang.Short) => n.asJson + case NumberValue(n: java.lang.Integer) => n.asJson + case NumberValue(n: java.lang.Long) => n.asJson + case NumberValue(n: java.lang.Float) => n.asJson + case NumberValue(n: java.lang.Double) => n.asJson + case NumberValue(n: java.math.BigDecimal) => n.asJson + case NumberValue(n: java.math.BigInteger) => n.asJson + case NumberValue(n: BigDecimal) => n.asJson + case NumberValue(n: BigInt) => n.asJson + case NumberValue(n) => n.doubleValue.asJson + } + + val Header = "X-Amzn-Trace-Id" + + final case class XRayHeader( + traceId: String, + parentId: Option[String], + sampled: Boolean + ) + + private def parseHeader(header: String): Option[XRayHeader] = { + val foo = header + .split(';') + .toList + .flatMap(_.split('=') match { + case Array(k, v) => List((k, v)) + case _ => List.empty + }) + .toList + .toMap + + foo + .get("Root") + .map(traceId => + XRayHeader(traceId, foo.get("Parent"), foo.get("Sampled").contains("1")) + ) + } + + private def now[F[_]: Sync]: F[Instant] = + Sync[F].delay(Instant.now) + + private def randomHexString[F[_]: Sync](bytes: Int): F[String] = + Random.scalaUtilRandom + .flatMap(_.nextBytes(bytes)) + .map(x => BigInt(1, x).toString(16).reverse.padTo(bytes * 2, '0').reverse) + + private def segmentId[F[_]: Sync]: F[String] = + randomHexString(8) + + private def traceId[F[_]: Sync]: F[String] = for { + t <- now + r <- randomHexString(12) + } yield s"1-${t.getEpochSecond.toHexString}-$r" + + def fromHeader[F[_]: Sync]( + name: String, + header: XRayHeader, + entry: XRayEntryPoint[F] + ): F[XRaySpan[F]] = for { + sId <- segmentId + t <- now + fields <- Ref[F].of(Map.empty[String, Json]) + children <- Ref[F].of(List.empty[JsonObject]) + } yield XRaySpan( + entry = entry, + name = name, + segmentId = sId, + xrayTraceId = header.traceId, + startTime = t, + fields = fields, + children = children, + parent = header.parentId.map(_.asLeft), + sampled = header.sampled + ) + + def fromKernel[F[_]: Sync]( + name: String, + kernel: Kernel, + entry: XRayEntryPoint[F] + ): F[XRaySpan[F]] = + kernel.toHeaders + .get(Header) + .flatMap(parseHeader) + .map(x => fromHeader(name, x, entry)) + .get + + def fromKernelOrElseRoot[F[_]: Sync]( + name: String, + kernel: Kernel, + entry: XRayEntryPoint[F] + ): F[XRaySpan[F]] = + kernel.toHeaders + .get(Header) + .flatMap(parseHeader) + .map(x => fromHeader(name, x, entry)) + .getOrElse(root(name, entry)) + + def root[F[_]: Sync](name: String, entry: XRayEntryPoint[F]): F[XRaySpan[F]] = + for { + sId <- segmentId + tId <- traceId + t <- now + fields <- Ref[F].of(Map.empty[String, Json]) + children <- Ref[F].of(List.empty[JsonObject]) + } yield XRaySpan( + entry = entry, + name = name, + segmentId = sId, + xrayTraceId = tId, + startTime = t, + fields = fields, + children = children, + parent = None, + sampled = true + ) + + def child[F[_]: Sync](parent: XRaySpan[F], name: String): F[XRaySpan[F]] = + for { + sId <- segmentId + t <- now + fields <- Ref[F].of(Map.empty[String, Json]) + children <- Ref[F].of(List.empty[JsonObject]) + } yield XRaySpan( + entry = parent.entry, + name = name, + segmentId = sId, + xrayTraceId = parent.xrayTraceId, + startTime = t, + fields = fields, + children = children, + parent = Some(Right(parent)), + sampled = parent.sampled + ) + + def finish[F[_]: Sync]( + span: XRaySpan[F], + entryPoint: XRayEntryPoint[F], + exitCase: ExitCase + ): F[Unit] = for { + t <- now + j <- span.serialize(t, exitCase) + _ <- span.parent match { + case None | Some(Left(_)) => + entryPoint.sendSegment(j) // Only send the parent segment + case Some(Right(s)) => + s.children.update(j :: _) // All childrens update their parents + } + } yield () + +} From 35813706afd30aa3838dec7a2ab0145396b77679 Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Mon, 8 Nov 2021 13:16:40 -0600 Subject: [PATCH 046/178] fix Scala 3 build errors --- build.sbt | 5 ++--- project/plugins.sbt | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 1479e71d..ce3a4d11 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ val scala212Version = "2.12.12" val scala213Version = "2.13.5" -val scala30Version = "3.0.2" +val scala30Version = "3.1.0" val collectionCompatVersion = "2.4.4" @@ -324,7 +324,7 @@ lazy val xray = project description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", - "co.fs2" %%% "fs2-io" % "3.2.0" + "co.fs2" %%% "fs2-io" % "3.2.0", ) ) @@ -411,4 +411,3 @@ lazy val docs = project "org.slf4j" % "slf4j-simple" % "1.7.32", ) ) - diff --git a/project/plugins.sbt b/project/plugins.sbt index c755bb98..31dd41fd 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,7 +5,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.23") From 371a4f6546e66a41953e1ae35f44e65f7127fee2 Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Wed, 3 Nov 2021 12:15:10 -0500 Subject: [PATCH 047/178] enable SJS support for X-Ray module --- build.sbt | 9 +++++++-- .../src/main/scala/natchez/xray}/XRay.scala | 0 .../src/main/scala/natchez/xray}/XRayEntryPoint.scala | 0 .../src/main/scala/natchez/xray}/XRaySpan.scala | 0 4 files changed, 7 insertions(+), 2 deletions(-) rename modules/xray/{src/main/scala => shared/src/main/scala/natchez/xray}/XRay.scala (100%) rename modules/xray/{src/main/scala => shared/src/main/scala/natchez/xray}/XRayEntryPoint.scala (100%) rename modules/xray/{src/main/scala => shared/src/main/scala/natchez/xray}/XRaySpan.scala (100%) diff --git a/build.sbt b/build.sbt index ce3a4d11..a6448099 100644 --- a/build.sbt +++ b/build.sbt @@ -314,9 +314,9 @@ lazy val noop = crossProject(JSPlatform, JVMPlatform) scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), ) -lazy val xray = project +lazy val xray = crossProject(JSPlatform, JVMPlatform) .in(file("modules/xray")) - .dependsOn(coreJVM) + .dependsOn(core) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( @@ -327,6 +327,11 @@ lazy val xray = project "co.fs2" %%% "fs2-io" % "3.2.0", ) ) + .jsSettings( + Test / scalaJSStage := FastOptStage, + jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(), + scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), + ) lazy val mock = project .in(file("modules/mock")) diff --git a/modules/xray/src/main/scala/XRay.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala similarity index 100% rename from modules/xray/src/main/scala/XRay.scala rename to modules/xray/shared/src/main/scala/natchez/xray/XRay.scala diff --git a/modules/xray/src/main/scala/XRayEntryPoint.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala similarity index 100% rename from modules/xray/src/main/scala/XRayEntryPoint.scala rename to modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala diff --git a/modules/xray/src/main/scala/XRaySpan.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala similarity index 100% rename from modules/xray/src/main/scala/XRaySpan.scala rename to modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala From 00cad67315aed2ddb3272bf0aa4b738d8a0ba6a3 Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Wed, 3 Nov 2021 12:16:10 -0500 Subject: [PATCH 048/178] add XRayEnvironment for pulling X-Ray initialization info from the system environment (which is useful in Lambda functions) --- build.sbt | 1 + .../scala/natchez/xray/XRayEnvironment.scala | 35 +++++++++++++++++++ .../main/scala/natchez/xray/XRaySpan.scala | 23 +++++++++--- 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala diff --git a/build.sbt b/build.sbt index a6448099..85cffca8 100644 --- a/build.sbt +++ b/build.sbt @@ -325,6 +325,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", "co.fs2" %%% "fs2-io" % "3.2.0", + "com.comcast" %%% "ip4s-core" % "3.1.1", ) ) .jsSettings( diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala new file mode 100644 index 00000000..123f2339 --- /dev/null +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala @@ -0,0 +1,35 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez.xray + +import cats.data._ +import cats.effect._ +import com.comcast.ip4s.{IpAddress, SocketAddress} +import natchez.Kernel + +trait XRayEnvironment[F[_]] { + def daemonAddress: F[Option[SocketAddress[IpAddress]]] + def traceId: F[Option[String]] + def kernelFromEnvironment: F[Kernel] +} + +object XRayEnvironment { + def apply[F[_] : XRayEnvironment]: XRayEnvironment[F] = implicitly + + implicit def instance[F[_] : Sync]: XRayEnvironment[F] = new XRayEnvironment[F] { + override def daemonAddress: F[Option[SocketAddress[IpAddress]]] = + OptionT(Sync[F].delay(sys.env.get("AWS_XRAY_DAEMON_ADDRESS"))) + .subflatMap(SocketAddress.fromStringIp) + .value + + override def traceId: F[Option[String]] = + Sync[F].delay(sys.env.get("_X_AMZN_TRACE_ID")) + + override def kernelFromEnvironment: F[Kernel] = + OptionT(traceId) + .map(XRaySpan.XRayHeader(_, None, sampled = true).toKernel) + .getOrElse(Kernel(Map.empty)) + } +} diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala index 5de2ae90..a96e4d83 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala @@ -7,10 +7,10 @@ package natchez.xray import cats.effect._ import cats.syntax.all._ import cats.effect.Resource.ExitCase - import natchez._ import natchez.TraceValue._ import cats.effect.Resource + import java.net.URI import java.time.Instant import io.circe.JsonObject @@ -21,6 +21,8 @@ import cats.effect.kernel.Resource.ExitCase.Canceled import cats.effect.kernel.Resource.ExitCase.Errored import cats.effect.kernel.Resource.ExitCase.Succeeded +import scala.util.matching.Regex + private[xray] final case class XRaySpan[F[_]: Sync]( entry: XRayEntryPoint[F], name: String, @@ -81,6 +83,15 @@ private[xray] final case class XRaySpan[F[_]: Sync]( ) ) + val (badKeys: Map[String, Json], goodKeys: Map[String, Json]) = fs.partition { case (k, _) => + keyRegex.findFirstMatchIn(k).isDefined + } + + val fixedAnnotations = badKeys.map { case (k, v) => + keyRegex.replaceAllIn(k, "_") -> v + } + val allAnnotations: Map[String, Json] = (goodKeys + ("malformed_keys" -> badKeys.keys.mkString(",").asJson)) ++ fixedAnnotations + val fields: List[(String, Json)] = List( "name" -> name.asJson, @@ -89,7 +100,7 @@ private[xray] final case class XRaySpan[F[_]: Sync]( "end_time" -> toEpoch(end).asJson, "trace_id" -> xrayTraceId.asJson, "subsegments" -> cs.reverse.map(Json.fromJsonObject).asJson, - "annotations" -> fs.asJson + "annotations" -> allAnnotations.asJson ) ++ { exitCase match { case Canceled => List("fault" -> true.asJson) @@ -108,6 +119,8 @@ private[xray] final case class XRaySpan[F[_]: Sync]( private[xray] object XRaySpan { + private[XRaySpan] val keyRegex: Regex = """[^A-Za-z0-9_]""".r + implicit val EncodeTraceValue: Encoder[TraceValue] = Encoder.instance { case StringValue(s) => s.asJson @@ -131,7 +144,10 @@ private[xray] object XRaySpan { traceId: String, parentId: Option[String], sampled: Boolean - ) + ) { + def toKernel: Kernel = + Kernel(Map("X-Amzn-Trace-Id" -> s"Root=$traceId;Parent=$parentId;Sampled=${if (sampled) "1" else "0"}")) + } private def parseHeader(header: String): Option[XRayHeader] = { val foo = header @@ -141,7 +157,6 @@ private[xray] object XRaySpan { case Array(k, v) => List((k, v)) case _ => List.empty }) - .toList .toMap foo From baf85db8fdb16a8e855394a59ca4497bf311eb05 Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Mon, 8 Nov 2021 22:44:26 -0600 Subject: [PATCH 049/178] introduce platform-specific methods for getting information from the environment --- .../natchez/xray/PlatformEnvironment.scala | 18 ++++++++++++++++++ .../natchez/xray/PlatformEnvironment.scala | 9 +++++++++ .../scala/natchez/xray/XRayEnvironment.scala | 6 +++--- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 modules/xray/js/src/main/scala/natchez/xray/PlatformEnvironment.scala create mode 100644 modules/xray/jvm/src/main/scala/natchez/xray/PlatformEnvironment.scala diff --git a/modules/xray/js/src/main/scala/natchez/xray/PlatformEnvironment.scala b/modules/xray/js/src/main/scala/natchez/xray/PlatformEnvironment.scala new file mode 100644 index 00000000..e6403867 --- /dev/null +++ b/modules/xray/js/src/main/scala/natchez/xray/PlatformEnvironment.scala @@ -0,0 +1,18 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez.xray + +import scala.scalajs.js +import scala.scalajs.js.annotation.JSImport + +private[xray] trait PlatformEnvironment { + def env = process.env +} + +@js.native +@JSImport("process", JSImport.Default) +private[xray] object process extends js.Object { + def env: js.Dictionary[String] = js.native +} diff --git a/modules/xray/jvm/src/main/scala/natchez/xray/PlatformEnvironment.scala b/modules/xray/jvm/src/main/scala/natchez/xray/PlatformEnvironment.scala new file mode 100644 index 00000000..5066f553 --- /dev/null +++ b/modules/xray/jvm/src/main/scala/natchez/xray/PlatformEnvironment.scala @@ -0,0 +1,9 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez.xray + +private[xray] trait PlatformEnvironment { + def env = sys.env +} diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala index 123f2339..6962cd74 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala @@ -15,17 +15,17 @@ trait XRayEnvironment[F[_]] { def kernelFromEnvironment: F[Kernel] } -object XRayEnvironment { +object XRayEnvironment extends PlatformEnvironment { def apply[F[_] : XRayEnvironment]: XRayEnvironment[F] = implicitly implicit def instance[F[_] : Sync]: XRayEnvironment[F] = new XRayEnvironment[F] { override def daemonAddress: F[Option[SocketAddress[IpAddress]]] = - OptionT(Sync[F].delay(sys.env.get("AWS_XRAY_DAEMON_ADDRESS"))) + OptionT(Sync[F].delay(env.get("AWS_XRAY_DAEMON_ADDRESS"))) .subflatMap(SocketAddress.fromStringIp) .value override def traceId: F[Option[String]] = - Sync[F].delay(sys.env.get("_X_AMZN_TRACE_ID")) + Sync[F].delay(env.get("_X_AMZN_TRACE_ID")) override def kernelFromEnvironment: F[Kernel] = OptionT(traceId) From fe4b574e5734e8b33e97b34f07ac0bcafb8ef71d Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Mon, 8 Nov 2021 22:45:30 -0600 Subject: [PATCH 050/178] relax cats-effect constraints on XRay types --- .../src/main/scala/natchez/xray/XRay.scala | 7 +- .../scala/natchez/xray/XRayEntryPoint.scala | 6 +- .../main/scala/natchez/xray/XRaySpan.scala | 190 +++++++++--------- 3 files changed, 99 insertions(+), 104 deletions(-) diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala index 3a2a9178..8f0cfdf7 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala @@ -5,14 +5,15 @@ package natchez package xray -import natchez.EntryPoint -import cats.effect.{Resource, Sync} +import cats.Parallel +import cats.effect.std.Random +import cats.effect.{Clock, Concurrent, Resource} import com.comcast.ip4s._ import fs2.io.net.Network object XRay { - def entryPoint[F[_]: Sync: Network]( + def entryPoint[F[_] : Concurrent : Clock : Random : Parallel : Network]( daemonAddress: SocketAddress[IpAddress] = SocketAddress(ip"127.0.0.1", port"2000") ): Resource[F, EntryPoint[F]] = diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala index f943902d..4885e855 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala @@ -5,14 +5,16 @@ package natchez package xray +import cats.Parallel import cats.effect._ +import cats.effect.std.Random import cats.syntax.all._ import io.circe._ import io.circe.syntax._ import com.comcast.ip4s._ -import fs2.io.net.{DatagramSocket, Datagram} +import fs2.io.net.{Datagram, DatagramSocket} -final class XRayEntryPoint[F[_]: Sync]( +final class XRayEntryPoint[F[_] : Concurrent : Clock : Random : Parallel]( socket: DatagramSocket[F], daemonAddress: SocketAddress[IpAddress] ) extends EntryPoint[F] { diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala index a96e4d83..acdbeac7 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala @@ -4,6 +4,7 @@ package natchez.xray +import cats._ import cats.effect._ import cats.syntax.all._ import cats.effect.Resource.ExitCase @@ -12,7 +13,6 @@ import natchez.TraceValue._ import cats.effect.Resource import java.net.URI -import java.time.Instant import io.circe.JsonObject import cats.effect.std.Random import io.circe._ @@ -21,15 +21,16 @@ import cats.effect.kernel.Resource.ExitCase.Canceled import cats.effect.kernel.Resource.ExitCase.Errored import cats.effect.kernel.Resource.ExitCase.Succeeded +import scala.concurrent.duration._ import scala.util.matching.Regex -private[xray] final case class XRaySpan[F[_]: Sync]( +private[xray] final case class XRaySpan[F[_] : Concurrent : Clock : Random : Parallel]( entry: XRayEntryPoint[F], name: String, segmentId: String, xrayTraceId: String, parent: Option[Either[String, XRaySpan[F]]], - startTime: Instant, + startTime: FiniteDuration, fields: Ref[F, Map[String, Json]], children: Ref[F, List[JsonObject]], sampled: Boolean @@ -37,7 +38,7 @@ private[xray] final case class XRaySpan[F[_]: Sync]( import XRaySpan._ def put(fields: (String, TraceValue)*): F[Unit] = { - val fieldsToAdd = fields.map { case (k, v) => (k -> v.asJson) } + val fieldsToAdd = fields.map { case (k, v) => k -> v.asJson } this.fields.update(_ ++ fieldsToAdd.toMap) } @@ -53,28 +54,31 @@ private[xray] final case class XRaySpan[F[_]: Sync]( def spanId: F[Option[String]] = segmentId.some.pure[F] - def traceUri: F[Option[URI]] = Option.empty.pure[F] + def traceUri: F[Option[URI]] = none[URI].pure[F] - private def toEpoch(t: Instant): Double = - t.getEpochSecond().toDouble + t.getNano().toDouble / 1000000000 + /* The X-Ray documentation says to use microsecond resolution when available: + * https://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html#api-segmentdocuments-fields + */ + private def toEpochSeconds(t: FiniteDuration): Double = + t.toMicros.toDouble / 1000000 - def serialize(end: Instant, exitCase: ExitCase): F[JsonObject] = - (fields.get, children.get, XRaySpan.segmentId).mapN { (fs, cs, id) => + def serialize(end: FiniteDuration, exitCase: ExitCase): F[JsonObject] = + (fields.get, children.get, XRaySpan.segmentId[F]).parMapN { (fs, cs, id) => def exitFields(ex: Throwable): List[(String, Json)] = List( "fault" -> true.asJson, "cause" -> Json.obj( "exceptions" -> Json.arr( Json.obj( "id" -> id.asJson, - "message" -> ex.getMessage().asJson, - "type" -> ex.getClass().getName().asJson, + "message" -> ex.getMessage.asJson, + "type" -> ex.getClass.getName.asJson, "stack" -> ex - .getStackTrace() + .getStackTrace .map(x => Json.obj( - "line" -> x.getLineNumber().asJson, - "path" -> x.getFileName().asJson, - "label" -> x.getMethodName().asJson + "line" -> x.getLineNumber.asJson, + "path" -> x.getFileName.asJson, + "label" -> x.getMethodName.asJson ) ) .asJson @@ -96,8 +100,8 @@ private[xray] final case class XRaySpan[F[_]: Sync]( List( "name" -> name.asJson, "id" -> segmentId.asJson, - "start_time" -> toEpoch(startTime).asJson, - "end_time" -> toEpoch(end).asJson, + "start_time" -> toEpochSeconds(startTime).asJson, + "end_time" -> toEpochSeconds(end).asJson, "trace_id" -> xrayTraceId.asJson, "subsegments" -> cs.reverse.map(Json.fromJsonObject).asJson, "annotations" -> allAnnotations.asJson @@ -166,108 +170,96 @@ private[xray] object XRaySpan { ) } - private def now[F[_]: Sync]: F[Instant] = - Sync[F].delay(Instant.now) - - private def randomHexString[F[_]: Sync](bytes: Int): F[String] = - Random.scalaUtilRandom - .flatMap(_.nextBytes(bytes)) + private def randomHexString[F[_] : Functor : Random](bytes: Int): F[String] = + Random[F].nextBytes(bytes) .map(x => BigInt(1, x).toString(16).reverse.padTo(bytes * 2, '0').reverse) - private def segmentId[F[_]: Sync]: F[String] = - randomHexString(8) - - private def traceId[F[_]: Sync]: F[String] = for { - t <- now - r <- randomHexString(12) - } yield s"1-${t.getEpochSecond.toHexString}-$r" - - def fromHeader[F[_]: Sync]( - name: String, - header: XRayHeader, - entry: XRayEntryPoint[F] - ): F[XRaySpan[F]] = for { - sId <- segmentId - t <- now - fields <- Ref[F].of(Map.empty[String, Json]) - children <- Ref[F].of(List.empty[JsonObject]) - } yield XRaySpan( - entry = entry, - name = name, - segmentId = sId, - xrayTraceId = header.traceId, - startTime = t, - fields = fields, - children = children, - parent = header.parentId.map(_.asLeft), - sampled = header.sampled - ) - - def fromKernel[F[_]: Sync]( - name: String, - kernel: Kernel, - entry: XRayEntryPoint[F] - ): F[XRaySpan[F]] = + private def segmentId[F[_] : Functor : Random]: F[String] = + randomHexString[F](8) + + private def traceId[F[_] : Applicative : Clock : Random : Parallel]: F[String] = + (Clock[F].realTime, randomHexString[F](12)).parMapN { (t, r) => + s"1-${t.toSeconds.toHexString}-$r" + } + + def fromHeader[F[_] : Concurrent : Clock : Random : Parallel](name: String, + header: XRayHeader, + entry: XRayEntryPoint[F] + ): F[XRaySpan[F]] = + (segmentId[F], Clock[F].realTime, Ref[F].of(Map.empty[String, Json]), Ref[F].of(List.empty[JsonObject])) + .parMapN { (sId, t, fields, children) => + XRaySpan( + entry = entry, + name = name, + segmentId = sId, + xrayTraceId = header.traceId, + startTime = t, + fields = fields, + children = children, + parent = header.parentId.map(_.asLeft), + sampled = header.sampled + ) + } + + def fromKernel[F[_] : Concurrent : Clock : Random : Parallel](name: String, + kernel: Kernel, + entry: XRayEntryPoint[F] + ): F[XRaySpan[F]] = kernel.toHeaders .get(Header) .flatMap(parseHeader) .map(x => fromHeader(name, x, entry)) .get - def fromKernelOrElseRoot[F[_]: Sync]( - name: String, - kernel: Kernel, - entry: XRayEntryPoint[F] - ): F[XRaySpan[F]] = + def fromKernelOrElseRoot[F[_] : Concurrent : Clock : Random : Parallel](name: String, + kernel: Kernel, + entry: XRayEntryPoint[F] + ): F[XRaySpan[F]] = kernel.toHeaders .get(Header) .flatMap(parseHeader) .map(x => fromHeader(name, x, entry)) .getOrElse(root(name, entry)) - def root[F[_]: Sync](name: String, entry: XRayEntryPoint[F]): F[XRaySpan[F]] = - for { - sId <- segmentId - tId <- traceId - t <- now - fields <- Ref[F].of(Map.empty[String, Json]) - children <- Ref[F].of(List.empty[JsonObject]) - } yield XRaySpan( - entry = entry, - name = name, - segmentId = sId, - xrayTraceId = tId, - startTime = t, - fields = fields, - children = children, - parent = None, - sampled = true - ) + def root[F[_] : Concurrent : Clock : Random : Parallel](name: String, + entry: XRayEntryPoint[F]): F[XRaySpan[F]] = + (segmentId[F], traceId[F], Clock[F].realTime, Ref[F].of(Map.empty[String, Json]), Ref[F].of(List.empty[JsonObject])) + .parMapN { (sId, tId, t, fields, children) => + XRaySpan( + entry = entry, + name = name, + segmentId = sId, + xrayTraceId = tId, + startTime = t, + fields = fields, + children = children, + parent = None, + sampled = true + ) + } - def child[F[_]: Sync](parent: XRaySpan[F], name: String): F[XRaySpan[F]] = - for { - sId <- segmentId - t <- now - fields <- Ref[F].of(Map.empty[String, Json]) - children <- Ref[F].of(List.empty[JsonObject]) - } yield XRaySpan( - entry = parent.entry, - name = name, - segmentId = sId, - xrayTraceId = parent.xrayTraceId, - startTime = t, - fields = fields, - children = children, - parent = Some(Right(parent)), - sampled = parent.sampled - ) + def child[F[_] : Concurrent : Clock : Random : Parallel](parent: XRaySpan[F], + name: String): F[XRaySpan[F]] = + (segmentId[F], Clock[F].realTime, Ref[F].of(Map.empty[String, Json]), Ref[F].of(List.empty[JsonObject])).parMapN { (sId, t, fields, children) => + XRaySpan( + entry = parent.entry, + name = name, + segmentId = sId, + xrayTraceId = parent.xrayTraceId, + startTime = t, + fields = fields, + children = children, + parent = Some(Right(parent)), + sampled = parent.sampled + ) + } - def finish[F[_]: Sync]( + def finish[F[_] : Clock : Monad]( span: XRaySpan[F], entryPoint: XRayEntryPoint[F], exitCase: ExitCase ): F[Unit] = for { - t <- now + t <- Clock[F].realTime j <- span.serialize(t, exitCase) _ <- span.parent match { case None | Some(Left(_)) => From 5313e7e9864149a21be8c7082403aa4acc23f154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kj=C3=A6r=20Larsen?= Date: Wed, 10 Nov 2021 16:38:41 +0100 Subject: [PATCH 051/178] Review changes --- build.sbt | 2 +- ...nt.scala => XRayEnvironmentCompanionPlatform.scala} | 2 +- ...nt.scala => XRayEnvironmentCompanionPlatform.scala} | 2 +- .../src/main/scala/natchez/xray/XRayEntryPoint.scala | 4 ++-- .../src/main/scala/natchez/xray/XRayEnvironment.scala | 2 +- .../shared/src/main/scala/natchez/xray/XRaySpan.scala | 10 ++++++++-- 6 files changed, 14 insertions(+), 8 deletions(-) rename modules/xray/js/src/main/scala/natchez/xray/{PlatformEnvironment.scala => XRayEnvironmentCompanionPlatform.scala} (89%) rename modules/xray/jvm/src/main/scala/natchez/xray/{PlatformEnvironment.scala => XRayEnvironmentCompanionPlatform.scala} (81%) diff --git a/build.sbt b/build.sbt index 85cffca8..73f3e728 100644 --- a/build.sbt +++ b/build.sbt @@ -324,7 +324,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", - "co.fs2" %%% "fs2-io" % "3.2.0", + "co.fs2" %%% "fs2-io" % "3.2.2", "com.comcast" %%% "ip4s-core" % "3.1.1", ) ) diff --git a/modules/xray/js/src/main/scala/natchez/xray/PlatformEnvironment.scala b/modules/xray/js/src/main/scala/natchez/xray/XRayEnvironmentCompanionPlatform.scala similarity index 89% rename from modules/xray/js/src/main/scala/natchez/xray/PlatformEnvironment.scala rename to modules/xray/js/src/main/scala/natchez/xray/XRayEnvironmentCompanionPlatform.scala index e6403867..885621fb 100644 --- a/modules/xray/js/src/main/scala/natchez/xray/PlatformEnvironment.scala +++ b/modules/xray/js/src/main/scala/natchez/xray/XRayEnvironmentCompanionPlatform.scala @@ -7,7 +7,7 @@ package natchez.xray import scala.scalajs.js import scala.scalajs.js.annotation.JSImport -private[xray] trait PlatformEnvironment { +private[xray] trait XRayEnvironmentCompanionPlatform { def env = process.env } diff --git a/modules/xray/jvm/src/main/scala/natchez/xray/PlatformEnvironment.scala b/modules/xray/jvm/src/main/scala/natchez/xray/XRayEnvironmentCompanionPlatform.scala similarity index 81% rename from modules/xray/jvm/src/main/scala/natchez/xray/PlatformEnvironment.scala rename to modules/xray/jvm/src/main/scala/natchez/xray/XRayEnvironmentCompanionPlatform.scala index 5066f553..ad950bb7 100644 --- a/modules/xray/jvm/src/main/scala/natchez/xray/PlatformEnvironment.scala +++ b/modules/xray/jvm/src/main/scala/natchez/xray/XRayEnvironmentCompanionPlatform.scala @@ -4,6 +4,6 @@ package natchez.xray -private[xray] trait PlatformEnvironment { +private[xray] trait XRayEnvironmentCompanionPlatform { def env = sys.env } diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala index 4885e855..2671fbed 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala @@ -20,7 +20,7 @@ final class XRayEntryPoint[F[_] : Concurrent : Clock : Random : Parallel]( ) extends EntryPoint[F] { def sendSegment(foo: JsonObject): F[Unit] = { - val payload = (XRayEntryPoint.header + foo.asJson.noSpaces).getBytes() + val payload = XRayEntryPoint.header ++ foo.asJson.noSpaces.getBytes() val datagram = Datagram(daemonAddress, fs2.Chunk.array(payload)) socket.write(datagram) } @@ -39,5 +39,5 @@ final class XRayEntryPoint[F[_] : Concurrent : Clock : Random : Parallel]( } object XRayEntryPoint { - val header = "{\"format\": \"json\", \"version\": 1}\n" + val header = "{\"format\": \"json\", \"version\": 1}\n".getBytes() } diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala index 6962cd74..9e5c034c 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala @@ -15,7 +15,7 @@ trait XRayEnvironment[F[_]] { def kernelFromEnvironment: F[Kernel] } -object XRayEnvironment extends PlatformEnvironment { +object XRayEnvironment extends XRayEnvironmentCompanionPlatform { def apply[F[_] : XRayEnvironment]: XRayEnvironment[F] = implicitly implicit def instance[F[_] : Sync]: XRayEnvironment[F] = new XRayEnvironment[F] { diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala index acdbeac7..4db95cc8 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala @@ -117,7 +117,7 @@ private[xray] final case class XRaySpan[F[_] : Concurrent : Clock : Random : Par } private def header: String = - s"Root=$xrayTraceId;Parent=$segmentId;Sampled=${if (sampled) "1" else "0"}" + encodeHeader(xrayTraceId, Some(segmentId), sampled) } @@ -144,13 +144,19 @@ private[xray] object XRaySpan { val Header = "X-Amzn-Trace-Id" + private[XRaySpan] def encodeHeader(rootId: String, parentId: Option[String], sampled: Boolean): String = { + val parent = parentId.map(p => s"Parent=$p;").getOrElse("") + s"Root=$rootId;${parent}Sampled=${if (sampled) "1" else "0"}" + } + + final case class XRayHeader( traceId: String, parentId: Option[String], sampled: Boolean ) { def toKernel: Kernel = - Kernel(Map("X-Amzn-Trace-Id" -> s"Root=$traceId;Parent=$parentId;Sampled=${if (sampled) "1" else "0"}")) + Kernel(Map(Header -> encodeHeader(traceId, parentId, sampled))) } private def parseHeader(header: String): Option[XRayHeader] = { From 4152220da150e8dfc10b542f4bff1e600eccb798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kj=C3=A6r=20Larsen?= Date: Fri, 12 Nov 2021 09:58:17 +0100 Subject: [PATCH 052/178] Review and fmt --- .../src/main/scala/natchez/xray/XRay.scala | 3 +- .../scala/natchez/xray/XRayEntryPoint.scala | 3 +- .../scala/natchez/xray/XRayEnvironment.scala | 27 ++--- .../main/scala/natchez/xray/XRaySpan.scala | 104 +++++++++++------- 4 files changed, 83 insertions(+), 54 deletions(-) diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala index 8f0cfdf7..a73439db 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala @@ -5,7 +5,6 @@ package natchez package xray -import cats.Parallel import cats.effect.std.Random import cats.effect.{Clock, Concurrent, Resource} import com.comcast.ip4s._ @@ -13,7 +12,7 @@ import fs2.io.net.Network object XRay { - def entryPoint[F[_] : Concurrent : Clock : Random : Parallel : Network]( + def entryPoint[F[_]: Concurrent: Clock: Random: Network]( daemonAddress: SocketAddress[IpAddress] = SocketAddress(ip"127.0.0.1", port"2000") ): Resource[F, EntryPoint[F]] = diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala index 2671fbed..b3c9ee68 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala @@ -5,7 +5,6 @@ package natchez package xray -import cats.Parallel import cats.effect._ import cats.effect.std.Random import cats.syntax.all._ @@ -14,7 +13,7 @@ import io.circe.syntax._ import com.comcast.ip4s._ import fs2.io.net.{Datagram, DatagramSocket} -final class XRayEntryPoint[F[_] : Concurrent : Clock : Random : Parallel]( +final class XRayEntryPoint[F[_]: Concurrent: Clock: Random]( socket: DatagramSocket[F], daemonAddress: SocketAddress[IpAddress] ) extends EntryPoint[F] { diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala index 9e5c034c..524d088c 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala @@ -16,20 +16,21 @@ trait XRayEnvironment[F[_]] { } object XRayEnvironment extends XRayEnvironmentCompanionPlatform { - def apply[F[_] : XRayEnvironment]: XRayEnvironment[F] = implicitly + def apply[F[_]: XRayEnvironment]: XRayEnvironment[F] = implicitly - implicit def instance[F[_] : Sync]: XRayEnvironment[F] = new XRayEnvironment[F] { - override def daemonAddress: F[Option[SocketAddress[IpAddress]]] = - OptionT(Sync[F].delay(env.get("AWS_XRAY_DAEMON_ADDRESS"))) - .subflatMap(SocketAddress.fromStringIp) - .value + implicit def instance[F[_]: Sync]: XRayEnvironment[F] = + new XRayEnvironment[F] { + override def daemonAddress: F[Option[SocketAddress[IpAddress]]] = + OptionT(Sync[F].delay(env.get("AWS_XRAY_DAEMON_ADDRESS"))) + .subflatMap(SocketAddress.fromStringIp) + .value - override def traceId: F[Option[String]] = - Sync[F].delay(env.get("_X_AMZN_TRACE_ID")) + override def traceId: F[Option[String]] = + Sync[F].delay(env.get("_X_AMZN_TRACE_ID")) - override def kernelFromEnvironment: F[Kernel] = - OptionT(traceId) - .map(XRaySpan.XRayHeader(_, None, sampled = true).toKernel) - .getOrElse(Kernel(Map.empty)) - } + override def kernelFromEnvironment: F[Kernel] = + OptionT(traceId) + .map(XRaySpan.XRayHeader(_, None, sampled = true).toKernel) + .getOrElse(Kernel(Map.empty)) + } } diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala index 4db95cc8..1ca8ac33 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala @@ -24,7 +24,7 @@ import cats.effect.kernel.Resource.ExitCase.Succeeded import scala.concurrent.duration._ import scala.util.matching.Regex -private[xray] final case class XRaySpan[F[_] : Concurrent : Clock : Random : Parallel]( +private[xray] final case class XRaySpan[F[_]: Concurrent: Clock: Random]( entry: XRayEntryPoint[F], name: String, segmentId: String, @@ -63,7 +63,7 @@ private[xray] final case class XRaySpan[F[_] : Concurrent : Clock : Random : Par t.toMicros.toDouble / 1000000 def serialize(end: FiniteDuration, exitCase: ExitCase): F[JsonObject] = - (fields.get, children.get, XRaySpan.segmentId[F]).parMapN { (fs, cs, id) => + (fields.get, children.get, XRaySpan.segmentId[F]).mapN { (fs, cs, id) => def exitFields(ex: Throwable): List[(String, Json)] = List( "fault" -> true.asJson, "cause" -> Json.obj( @@ -72,8 +72,7 @@ private[xray] final case class XRaySpan[F[_] : Concurrent : Clock : Random : Par "id" -> id.asJson, "message" -> ex.getMessage.asJson, "type" -> ex.getClass.getName.asJson, - "stack" -> ex - .getStackTrace + "stack" -> ex.getStackTrace .map(x => Json.obj( "line" -> x.getLineNumber.asJson, @@ -87,14 +86,18 @@ private[xray] final case class XRaySpan[F[_] : Concurrent : Clock : Random : Par ) ) - val (badKeys: Map[String, Json], goodKeys: Map[String, Json]) = fs.partition { case (k, _) => - keyRegex.findFirstMatchIn(k).isDefined - } + val (badKeys: Map[String, Json], goodKeys: Map[String, Json]) = + fs.partition { case (k, _) => + keyRegex.findFirstMatchIn(k).isDefined + } val fixedAnnotations = badKeys.map { case (k, v) => keyRegex.replaceAllIn(k, "_") -> v } - val allAnnotations: Map[String, Json] = (goodKeys + ("malformed_keys" -> badKeys.keys.mkString(",").asJson)) ++ fixedAnnotations + val allAnnotations: Map[String, Json] = + (goodKeys + ("malformed_keys" -> badKeys.keys + .mkString(",") + .asJson)) ++ fixedAnnotations val fields: List[(String, Json)] = List( @@ -144,11 +147,14 @@ private[xray] object XRaySpan { val Header = "X-Amzn-Trace-Id" - private[XRaySpan] def encodeHeader(rootId: String, parentId: Option[String], sampled: Boolean): String = { + private[XRaySpan] def encodeHeader( + rootId: String, + parentId: Option[String], + sampled: Boolean + ): String = { val parent = parentId.map(p => s"Parent=$p;").getOrElse("") s"Root=$rootId;${parent}Sampled=${if (sampled) "1" else "0"}" } - final case class XRayHeader( traceId: String, @@ -176,24 +182,31 @@ private[xray] object XRaySpan { ) } - private def randomHexString[F[_] : Functor : Random](bytes: Int): F[String] = - Random[F].nextBytes(bytes) + private def randomHexString[F[_]: Functor: Random](bytes: Int): F[String] = + Random[F] + .nextBytes(bytes) .map(x => BigInt(1, x).toString(16).reverse.padTo(bytes * 2, '0').reverse) - private def segmentId[F[_] : Functor : Random]: F[String] = + private def segmentId[F[_]: Functor: Random]: F[String] = randomHexString[F](8) - private def traceId[F[_] : Applicative : Clock : Random : Parallel]: F[String] = - (Clock[F].realTime, randomHexString[F](12)).parMapN { (t, r) => + private def traceId[F[_]: Applicative: Clock: Random]: F[String] = + (Clock[F].realTime, randomHexString[F](12)).mapN { (t, r) => s"1-${t.toSeconds.toHexString}-$r" } - def fromHeader[F[_] : Concurrent : Clock : Random : Parallel](name: String, - header: XRayHeader, - entry: XRayEntryPoint[F] - ): F[XRaySpan[F]] = - (segmentId[F], Clock[F].realTime, Ref[F].of(Map.empty[String, Json]), Ref[F].of(List.empty[JsonObject])) - .parMapN { (sId, t, fields, children) => + def fromHeader[F[_]: Concurrent: Clock: Random]( + name: String, + header: XRayHeader, + entry: XRayEntryPoint[F] + ): F[XRaySpan[F]] = + ( + segmentId[F], + Clock[F].realTime, + Ref[F].of(Map.empty[String, Json]), + Ref[F].of(List.empty[JsonObject]) + ) + .mapN { (sId, t, fields, children) => XRaySpan( entry = entry, name = name, @@ -207,30 +220,40 @@ private[xray] object XRaySpan { ) } - def fromKernel[F[_] : Concurrent : Clock : Random : Parallel](name: String, - kernel: Kernel, - entry: XRayEntryPoint[F] - ): F[XRaySpan[F]] = + def fromKernel[F[_]: Concurrent: Clock: Random]( + name: String, + kernel: Kernel, + entry: XRayEntryPoint[F] + ): F[XRaySpan[F]] = kernel.toHeaders .get(Header) .flatMap(parseHeader) .map(x => fromHeader(name, x, entry)) .get - def fromKernelOrElseRoot[F[_] : Concurrent : Clock : Random : Parallel](name: String, - kernel: Kernel, - entry: XRayEntryPoint[F] - ): F[XRaySpan[F]] = + def fromKernelOrElseRoot[F[_]: Concurrent: Clock: Random]( + name: String, + kernel: Kernel, + entry: XRayEntryPoint[F] + ): F[XRaySpan[F]] = kernel.toHeaders .get(Header) .flatMap(parseHeader) .map(x => fromHeader(name, x, entry)) .getOrElse(root(name, entry)) - def root[F[_] : Concurrent : Clock : Random : Parallel](name: String, - entry: XRayEntryPoint[F]): F[XRaySpan[F]] = - (segmentId[F], traceId[F], Clock[F].realTime, Ref[F].of(Map.empty[String, Json]), Ref[F].of(List.empty[JsonObject])) - .parMapN { (sId, tId, t, fields, children) => + def root[F[_]: Concurrent: Clock: Random]( + name: String, + entry: XRayEntryPoint[F] + ): F[XRaySpan[F]] = + ( + segmentId[F], + traceId[F], + Clock[F].realTime, + Ref[F].of(Map.empty[String, Json]), + Ref[F].of(List.empty[JsonObject]) + ) + .mapN { (sId, tId, t, fields, children) => XRaySpan( entry = entry, name = name, @@ -244,9 +267,16 @@ private[xray] object XRaySpan { ) } - def child[F[_] : Concurrent : Clock : Random : Parallel](parent: XRaySpan[F], - name: String): F[XRaySpan[F]] = - (segmentId[F], Clock[F].realTime, Ref[F].of(Map.empty[String, Json]), Ref[F].of(List.empty[JsonObject])).parMapN { (sId, t, fields, children) => + def child[F[_]: Concurrent: Clock: Random]( + parent: XRaySpan[F], + name: String + ): F[XRaySpan[F]] = + ( + segmentId[F], + Clock[F].realTime, + Ref[F].of(Map.empty[String, Json]), + Ref[F].of(List.empty[JsonObject]) + ).mapN { (sId, t, fields, children) => XRaySpan( entry = parent.entry, name = name, @@ -260,7 +290,7 @@ private[xray] object XRaySpan { ) } - def finish[F[_] : Clock : Monad]( + def finish[F[_]: Clock: Monad]( span: XRaySpan[F], entryPoint: XRayEntryPoint[F], exitCase: ExitCase From a0f679c6644323d75bf7d813cf8006ab700a4853 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 12 Nov 2021 19:08:13 +0100 Subject: [PATCH 053/178] Update grpc-netty to 1.42.1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 389f8d9b..6b7fa23e 100644 --- a/build.sbt +++ b/build.sbt @@ -190,7 +190,7 @@ lazy val lightstepGrpc = project description := "Lightstep gRPC bindings for Natchez.", libraryDependencies ++= Seq( "com.lightstep.tracer" % "tracer-grpc" % "0.30.3", - "io.grpc" % "grpc-netty" % "1.38.1", + "io.grpc" % "grpc-netty" % "1.42.1", "io.netty" % "netty-tcnative-boringssl-static" % "2.0.39.Final" ) ) From 2757a46b67c39449bcfbaf00e65e39fc133d2125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kj=C3=A6r=20Larsen?= Date: Sun, 14 Nov 2021 12:51:17 +0100 Subject: [PATCH 054/178] Added test --- build.sbt | 1 + .../src/main/scala/natchez/xray/XRay.scala | 1 + .../main/scala/natchez/xray/XRaySpan.scala | 4 +- .../shared/src/test/scala/XRaySuite.scala | 50 +++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 modules/xray/shared/src/test/scala/XRaySuite.scala diff --git a/build.sbt b/build.sbt index 73f3e728..6b5b2f0f 100644 --- a/build.sbt +++ b/build.sbt @@ -319,6 +319,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) .dependsOn(core) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) + .settings(crossProjectSettings) .settings( name := "natchez-xray", description := "AWS X-Ray bindings implementation", diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala index a73439db..51bfd7b6 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala @@ -21,4 +21,5 @@ object XRay { .map { socket => new XRayEntryPoint[F](socket, daemonAddress) } + } diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala index 1ca8ac33..6636df42 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala @@ -147,7 +147,7 @@ private[xray] object XRaySpan { val Header = "X-Amzn-Trace-Id" - private[XRaySpan] def encodeHeader( + private[xray] def encodeHeader( rootId: String, parentId: Option[String], sampled: Boolean @@ -165,7 +165,7 @@ private[xray] object XRaySpan { Kernel(Map(Header -> encodeHeader(traceId, parentId, sampled))) } - private def parseHeader(header: String): Option[XRayHeader] = { + private[xray] def parseHeader(header: String): Option[XRayHeader] = { val foo = header .split(';') .toList diff --git a/modules/xray/shared/src/test/scala/XRaySuite.scala b/modules/xray/shared/src/test/scala/XRaySuite.scala new file mode 100644 index 00000000..e29a6765 --- /dev/null +++ b/modules/xray/shared/src/test/scala/XRaySuite.scala @@ -0,0 +1,50 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez +package xray + +import munit.FunSuite + +class XRaySuite extends FunSuite { + + val rootId = "1-5759e988-bd862e3fe1be46a994272793" + val parentId = "53995c3f42cd8ad8" + + val noParent = "Root=1-5759e988-bd862e3fe1be46a994272793;Sampled=1" + val parent = + "Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1" + val notSampled = "Root=1-5759e988-bd862e3fe1be46a994272793;Sampled=0" + + test("header parsing") { + + assertEquals( + XRaySpan.parseHeader(noParent), + Some( + XRaySpan.XRayHeader("1-5759e988-bd862e3fe1be46a994272793", None, true) + ) + ) + + assertEquals( + XRaySpan.parseHeader(parent), + Some( + XRaySpan.XRayHeader( + "1-5759e988-bd862e3fe1be46a994272793", + Some("53995c3f42cd8ad8"), + true + ) + ) + ) + + assertEquals(XRaySpan.parseHeader(notSampled).map(_.sampled), Some(false)) + } + + test("header encoding") { + + assertEquals(XRaySpan.encodeHeader(rootId, None, true), noParent) + assertEquals(XRaySpan.encodeHeader(rootId, Some(parentId), true), parent) + assertEquals(XRaySpan.encodeHeader(rootId, None, false), notSampled) + } + +} From 0f7e4bf443ffc36d1066360324ebdc6649fc0dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kj=C3=A6r=20Larsen?= Date: Sun, 14 Nov 2021 20:08:33 +0100 Subject: [PATCH 055/178] Final review feedback --- build.sbt | 1 + .../scala/natchez/xray/XRayEntryPoint.scala | 10 +++-- .../main/scala/natchez/xray/XRaySpan.scala | 45 ++++++++++--------- .../shared/src/test/scala/XRaySuite.scala | 8 +--- 4 files changed, 33 insertions(+), 31 deletions(-) diff --git a/build.sbt b/build.sbt index 6b5b2f0f..6d59ac16 100644 --- a/build.sbt +++ b/build.sbt @@ -327,6 +327,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) "io.circe" %%% "circe-core" % "0.14.1", "co.fs2" %%% "fs2-io" % "3.2.2", "com.comcast" %%% "ip4s-core" % "3.1.1", + "org.scodec" %%% "scodec-bits" % "1.1.29" ) ) .jsSettings( diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala index b3c9ee68..f325dcef 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala @@ -12,6 +12,7 @@ import io.circe._ import io.circe.syntax._ import com.comcast.ip4s._ import fs2.io.net.{Datagram, DatagramSocket} +import scodec.bits.ByteVector final class XRayEntryPoint[F[_]: Concurrent: Clock: Random]( socket: DatagramSocket[F], @@ -19,8 +20,9 @@ final class XRayEntryPoint[F[_]: Concurrent: Clock: Random]( ) extends EntryPoint[F] { def sendSegment(foo: JsonObject): F[Unit] = { - val payload = XRayEntryPoint.header ++ foo.asJson.noSpaces.getBytes() - val datagram = Datagram(daemonAddress, fs2.Chunk.array(payload)) + val body = io.circe.Printer.noSpaces.printToByteBuffer(foo.asJson) + val payload = XRayEntryPoint.header ++ ByteVector.apply(body) + val datagram = Datagram(daemonAddress, fs2.Chunk.byteVector(payload)) socket.write(datagram) } @@ -38,5 +40,7 @@ final class XRayEntryPoint[F[_]: Concurrent: Clock: Random]( } object XRayEntryPoint { - val header = "{\"format\": \"json\", \"version\": 1}\n".getBytes() + val header = ByteVector + .encodeUtf8("{\"format\": \"json\", \"version\": 1}\n") + .getOrElse(ByteVector.empty) } diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala index 6636df42..d6bfc106 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala @@ -62,14 +62,15 @@ private[xray] final case class XRaySpan[F[_]: Concurrent: Clock: Random]( private def toEpochSeconds(t: FiniteDuration): Double = t.toMicros.toDouble / 1000000 - def serialize(end: FiniteDuration, exitCase: ExitCase): F[JsonObject] = - (fields.get, children.get, XRaySpan.segmentId[F]).mapN { (fs, cs, id) => - def exitFields(ex: Throwable): List[(String, Json)] = List( + implicit val exceptionEncoder: Encoder.AsObject[XRayException] = + Encoder.AsObject.instance { xex => + val ex = xex.ex + JsonObject( "fault" -> true.asJson, "cause" -> Json.obj( "exceptions" -> Json.arr( Json.obj( - "id" -> id.asJson, + "id" -> xex.id.asJson, "message" -> ex.getMessage.asJson, "type" -> ex.getClass.getName.asJson, "stack" -> ex.getStackTrace @@ -85,7 +86,10 @@ private[xray] final case class XRaySpan[F[_]: Concurrent: Clock: Random]( ) ) ) + } + def serialize(end: FiniteDuration, exitCase: ExitCase): F[JsonObject] = + (fields.get, children.get, XRaySpan.segmentId[F]).mapN { (fs, cs, id) => val (badKeys: Map[String, Json], goodKeys: Map[String, Json]) = fs.partition { case (k, _) => keyRegex.findFirstMatchIn(k).isDefined @@ -99,24 +103,19 @@ private[xray] final case class XRaySpan[F[_]: Concurrent: Clock: Random]( .mkString(",") .asJson)) ++ fixedAnnotations - val fields: List[(String, Json)] = - List( - "name" -> name.asJson, - "id" -> segmentId.asJson, - "start_time" -> toEpochSeconds(startTime).asJson, - "end_time" -> toEpochSeconds(end).asJson, - "trace_id" -> xrayTraceId.asJson, - "subsegments" -> cs.reverse.map(Json.fromJsonObject).asJson, - "annotations" -> allAnnotations.asJson - ) ++ { - exitCase match { - case Canceled => List("fault" -> true.asJson) - case Errored(e) => exitFields(e) - case Succeeded => List() - } - } - - JsonObject.fromIterable(fields) + JsonObject( + "name" -> name.asJson, + "id" -> segmentId.asJson, + "start_time" -> toEpochSeconds(startTime).asJson, + "end_time" -> toEpochSeconds(end).asJson, + "trace_id" -> xrayTraceId.asJson, + "subsegments" -> cs.reverse.map(Json.fromJsonObject).asJson, + "annotations" -> allAnnotations.asJson + ).deepMerge(exitCase match { + case Canceled => JsonObject.singleton("fault", true.asJson) + case Errored(e) => XRayException(id, e).asJsonObject + case Succeeded => JsonObject.empty + }) } private def header: String = @@ -128,6 +127,8 @@ private[xray] object XRaySpan { private[XRaySpan] val keyRegex: Regex = """[^A-Za-z0-9_]""".r + final case class XRayException(id: String, ex: Throwable) + implicit val EncodeTraceValue: Encoder[TraceValue] = Encoder.instance { case StringValue(s) => s.asJson diff --git a/modules/xray/shared/src/test/scala/XRaySuite.scala b/modules/xray/shared/src/test/scala/XRaySuite.scala index e29a6765..0cdc8bfb 100644 --- a/modules/xray/shared/src/test/scala/XRaySuite.scala +++ b/modules/xray/shared/src/test/scala/XRaySuite.scala @@ -22,18 +22,14 @@ class XRaySuite extends FunSuite { assertEquals( XRaySpan.parseHeader(noParent), Some( - XRaySpan.XRayHeader("1-5759e988-bd862e3fe1be46a994272793", None, true) + XRaySpan.XRayHeader(rootId, None, true) ) ) assertEquals( XRaySpan.parseHeader(parent), Some( - XRaySpan.XRayHeader( - "1-5759e988-bd862e3fe1be46a994272793", - Some("53995c3f42cd8ad8"), - true - ) + XRaySpan.XRayHeader(rootId, Some(parentId), true) ) ) From 400a17f408362c2f8c616504e9f6059d0cf47de4 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 17 Nov 2021 12:52:07 +0100 Subject: [PATCH 056/178] Update netty-tcnative-boringssl-static to 2.0.46.Final --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 389f8d9b..b672bf0d 100644 --- a/build.sbt +++ b/build.sbt @@ -191,7 +191,7 @@ lazy val lightstepGrpc = project libraryDependencies ++= Seq( "com.lightstep.tracer" % "tracer-grpc" % "0.30.3", "io.grpc" % "grpc-netty" % "1.38.1", - "io.netty" % "netty-tcnative-boringssl-static" % "2.0.39.Final" + "io.netty" % "netty-tcnative-boringssl-static" % "2.0.46.Final" ) ) From 0a1e6e013adf4bc86f553a2523234e3997902e41 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 17 Nov 2021 21:06:03 +0100 Subject: [PATCH 057/178] Update sbt-updates to 0.6.0 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 31dd41fd..60759521 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -4,7 +4,7 @@ addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") From fedee36de621bf99d81f0fe8e33b52a2df52f12a Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 17 Nov 2021 21:06:08 +0100 Subject: [PATCH 058/178] Update sbt-scalajs-crossproject to 1.1.0 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 31dd41fd..2b0bc2e5 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -6,6 +6,6 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.23") From 507365267d402b16356f8e62906c3e1a119788a1 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 17 Nov 2021 21:06:12 +0100 Subject: [PATCH 059/178] Update scala-library to 2.13.7 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 6d59ac16..eee17a05 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,5 @@ val scala212Version = "2.12.12" -val scala213Version = "2.13.5" +val scala213Version = "2.13.7" val scala30Version = "3.1.0" val collectionCompatVersion = "2.4.4" From 0f57f00eaf4fedef668d1c7fda4b8b64265e2a93 Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Wed, 17 Nov 2021 14:37:03 -0600 Subject: [PATCH 060/178] correctly parse XRay header when it comes from an environment variable --- .../shared/src/main/scala/natchez/xray/XRayEnvironment.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala index 524d088c..1ec05d85 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRayEnvironment.scala @@ -30,7 +30,8 @@ object XRayEnvironment extends XRayEnvironmentCompanionPlatform { override def kernelFromEnvironment: F[Kernel] = OptionT(traceId) - .map(XRaySpan.XRayHeader(_, None, sampled = true).toKernel) + .subflatMap(XRaySpan.parseHeader) + .map(_.toKernel) .getOrElse(Kernel(Map.empty)) } } From 248e65b6f6722aeebdd3b3af721bcd49304800e4 Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Wed, 17 Nov 2021 14:40:39 -0600 Subject: [PATCH 061/178] handle the case when XRaySpan.fromKernel does not return a value --- .../scala/natchez/xray/XRayEntryPoint.scala | 3 ++- .../main/scala/natchez/xray/XRaySpan.scala | 19 ++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala index f325dcef..bee1b4a2 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala @@ -5,6 +5,7 @@ package natchez package xray +import cats.data.OptionT import cats.effect._ import cats.effect.std.Random import cats.syntax.all._ @@ -33,7 +34,7 @@ final class XRayEntryPoint[F[_]: Concurrent: Clock: Random]( make(XRaySpan.root(name, this)) def continue(name: String, kernel: Kernel): Resource[F, Span[F]] = - make(XRaySpan.fromKernel(name, kernel, this)) + make(OptionT(XRaySpan.fromKernel(name, kernel, this)).getOrElseF(new NoSuchElementException().raiseError)) def continueOrElseRoot(name: String, kernel: Kernel): Resource[F, Span[F]] = make(XRaySpan.fromKernelOrElseRoot(name, kernel, this)) diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala index d6bfc106..51e7ac09 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala @@ -5,6 +5,7 @@ package natchez.xray import cats._ +import cats.data._ import cats.effect._ import cats.syntax.all._ import cats.effect.Resource.ExitCase @@ -225,23 +226,19 @@ private[xray] object XRaySpan { name: String, kernel: Kernel, entry: XRayEntryPoint[F] - ): F[XRaySpan[F]] = - kernel.toHeaders - .get(Header) - .flatMap(parseHeader) - .map(x => fromHeader(name, x, entry)) - .get + ): F[Option[XRaySpan[F]]] = + OptionT.fromOption[F](kernel.toHeaders.get(Header)) + .subflatMap(parseHeader) + .semiflatMap(fromHeader(name, _, entry)) + .value def fromKernelOrElseRoot[F[_]: Concurrent: Clock: Random]( name: String, kernel: Kernel, entry: XRayEntryPoint[F] ): F[XRaySpan[F]] = - kernel.toHeaders - .get(Header) - .flatMap(parseHeader) - .map(x => fromHeader(name, x, entry)) - .getOrElse(root(name, entry)) + OptionT(fromKernel(name, kernel, entry)) + .getOrElseF(root(name, entry)) def root[F[_]: Concurrent: Clock: Random]( name: String, From eac456aff959a5b51640e95f1db2006d9e32e65e Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Wed, 17 Nov 2021 14:45:20 -0600 Subject: [PATCH 062/178] when using XRay, try to pull the kernel from the environment if the user-passed kernel doesn't contain the necessary information --- .../shared/src/main/scala/natchez/xray/XRay.scala | 2 +- .../main/scala/natchez/xray/XRayEntryPoint.scala | 2 +- .../src/main/scala/natchez/xray/XRaySpan.scala | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala index 51bfd7b6..cb700a1e 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala @@ -12,7 +12,7 @@ import fs2.io.net.Network object XRay { - def entryPoint[F[_]: Concurrent: Clock: Random: Network]( + def entryPoint[F[_] : Concurrent : Clock : Random : Network : XRayEnvironment]( daemonAddress: SocketAddress[IpAddress] = SocketAddress(ip"127.0.0.1", port"2000") ): Resource[F, EntryPoint[F]] = diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala index bee1b4a2..dbf93951 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala @@ -15,7 +15,7 @@ import com.comcast.ip4s._ import fs2.io.net.{Datagram, DatagramSocket} import scodec.bits.ByteVector -final class XRayEntryPoint[F[_]: Concurrent: Clock: Random]( +final class XRayEntryPoint[F[_]: Concurrent: Clock: Random : XRayEnvironment]( socket: DatagramSocket[F], daemonAddress: SocketAddress[IpAddress] ) extends EntryPoint[F] { diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala index 51e7ac09..11c30037 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala @@ -222,17 +222,26 @@ private[xray] object XRaySpan { ) } - def fromKernel[F[_]: Concurrent: Clock: Random]( + def fromKernel[F[_] : Concurrent : Clock : Random : XRayEnvironment]( name: String, kernel: Kernel, - entry: XRayEntryPoint[F] + entry: XRayEntryPoint[F], + useEnvironmentFallback: Boolean = true, ): F[Option[XRaySpan[F]]] = OptionT.fromOption[F](kernel.toHeaders.get(Header)) .subflatMap(parseHeader) .semiflatMap(fromHeader(name, _, entry)) + .orElse { + OptionT.whenF(useEnvironmentFallback) { + XRayEnvironment[F] + .kernelFromEnvironment + .flatMap(XRaySpan.fromKernel(name, _, entry, useEnvironmentFallback = false)) + } + .flattenOption + } .value - def fromKernelOrElseRoot[F[_]: Concurrent: Clock: Random]( + def fromKernelOrElseRoot[F[_] : Concurrent : Clock : Random : XRayEnvironment]( name: String, kernel: Kernel, entry: XRayEntryPoint[F] From 02f789ef8b3821ce1f2e5e3296b72b73d84327ae Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 17 Nov 2021 17:58:31 -0500 Subject: [PATCH 063/178] Scalacheck prop for XRay header (#1) --- build.sbt | 3 +- .../shared/src/test/scala/XRaySuite.scala | 30 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 6d59ac16..ed839fe6 100644 --- a/build.sbt +++ b/build.sbt @@ -54,7 +54,8 @@ lazy val commonSettings = Seq( // Testing libraryDependencies ++= Seq( - "org.scalameta" %%% "munit" % "0.7.26" % Test, + "org.scalameta" %%% "munit" % "0.7.29" % Test, + "org.scalameta" %%% "munit-scalacheck" % "0.7.29" % Test, "org.typelevel" %%% "munit-cats-effect-3" % "1.0.3" % Test, ), testFrameworks += new TestFramework("munit.Framework"), diff --git a/modules/xray/shared/src/test/scala/XRaySuite.scala b/modules/xray/shared/src/test/scala/XRaySuite.scala index 0cdc8bfb..6fc92d94 100644 --- a/modules/xray/shared/src/test/scala/XRaySuite.scala +++ b/modules/xray/shared/src/test/scala/XRaySuite.scala @@ -5,9 +5,12 @@ package natchez package xray -import munit.FunSuite +import munit.ScalaCheckSuite +import org.scalacheck.Arbitrary +import org.scalacheck.Gen +import org.scalacheck.Prop._ -class XRaySuite extends FunSuite { +class XRaySuite extends ScalaCheckSuite { val rootId = "1-5759e988-bd862e3fe1be46a994272793" val parentId = "53995c3f42cd8ad8" @@ -17,6 +20,21 @@ class XRaySuite extends FunSuite { "Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1" val notSampled = "Root=1-5759e988-bd862e3fe1be46a994272793;Sampled=0" + val genTraceId = for { + time <- Gen.buildableOfN[String, Char](8, Gen.hexChar) + identifier <- Gen.buildableOfN[String, Char](24, Gen.hexChar) + } yield s"1-$time-$identifier" + + val genSegmentId = Gen.buildableOfN[String, Char](16, Gen.hexChar) + + val genHeader = for { + traceId <- genTraceId + parentId <- Gen.option(genSegmentId) + sampled <- Gen.prob(0.5) + } yield XRaySpan.XRayHeader(traceId, parentId, sampled) + + implicit val arbitraryHeader: Arbitrary[XRaySpan.XRayHeader] = Arbitrary(genHeader) + test("header parsing") { assertEquals( @@ -43,4 +61,12 @@ class XRaySuite extends FunSuite { assertEquals(XRaySpan.encodeHeader(rootId, None, false), notSampled) } + property("header encoding/parsing round-trip") { + forAll { (header: XRaySpan.XRayHeader) => + val encoded = XRaySpan.encodeHeader(header.traceId, header.parentId, header.sampled) + val parsed = XRaySpan.parseHeader(encoded) + assertEquals(parsed, Some(header)) + } + } + } From 0c2c076f04745a272ce69a5998bf8004d6de48f8 Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Thu, 18 Nov 2021 16:19:39 -0600 Subject: [PATCH 064/178] thread useEnvironmentFallback setting through from XRay EntryPoint constructor to span creation --- modules/xray/shared/src/main/scala/natchez/xray/XRay.scala | 5 +++-- .../src/main/scala/natchez/xray/XRayEntryPoint.scala | 7 ++++--- .../xray/shared/src/main/scala/natchez/xray/XRaySpan.scala | 7 ++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala index cb700a1e..8d5d7e56 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRay.scala @@ -14,12 +14,13 @@ object XRay { def entryPoint[F[_] : Concurrent : Clock : Random : Network : XRayEnvironment]( daemonAddress: SocketAddress[IpAddress] = - SocketAddress(ip"127.0.0.1", port"2000") + SocketAddress(ip"127.0.0.1", port"2000"), + useEnvironmentFallback: Boolean = true ): Resource[F, EntryPoint[F]] = Network[F] .openDatagramSocket() .map { socket => - new XRayEntryPoint[F](socket, daemonAddress) + new XRayEntryPoint[F](socket, daemonAddress, useEnvironmentFallback) } } diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala index dbf93951..837d7112 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRayEntryPoint.scala @@ -17,7 +17,8 @@ import scodec.bits.ByteVector final class XRayEntryPoint[F[_]: Concurrent: Clock: Random : XRayEnvironment]( socket: DatagramSocket[F], - daemonAddress: SocketAddress[IpAddress] + daemonAddress: SocketAddress[IpAddress], + useEnvironmentFallback: Boolean, ) extends EntryPoint[F] { def sendSegment(foo: JsonObject): F[Unit] = { @@ -34,10 +35,10 @@ final class XRayEntryPoint[F[_]: Concurrent: Clock: Random : XRayEnvironment]( make(XRaySpan.root(name, this)) def continue(name: String, kernel: Kernel): Resource[F, Span[F]] = - make(OptionT(XRaySpan.fromKernel(name, kernel, this)).getOrElseF(new NoSuchElementException().raiseError)) + make(OptionT(XRaySpan.fromKernel(name, kernel, this, useEnvironmentFallback)).getOrElseF(new NoSuchElementException().raiseError)) def continueOrElseRoot(name: String, kernel: Kernel): Resource[F, Span[F]] = - make(XRaySpan.fromKernelOrElseRoot(name, kernel, this)) + make(XRaySpan.fromKernelOrElseRoot(name, kernel, this, useEnvironmentFallback)) } object XRayEntryPoint { diff --git a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala index 11c30037..446c2d34 100644 --- a/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala +++ b/modules/xray/shared/src/main/scala/natchez/xray/XRaySpan.scala @@ -226,7 +226,7 @@ private[xray] object XRaySpan { name: String, kernel: Kernel, entry: XRayEntryPoint[F], - useEnvironmentFallback: Boolean = true, + useEnvironmentFallback: Boolean, ): F[Option[XRaySpan[F]]] = OptionT.fromOption[F](kernel.toHeaders.get(Header)) .subflatMap(parseHeader) @@ -244,9 +244,10 @@ private[xray] object XRaySpan { def fromKernelOrElseRoot[F[_] : Concurrent : Clock : Random : XRayEnvironment]( name: String, kernel: Kernel, - entry: XRayEntryPoint[F] + entry: XRayEntryPoint[F], + useEnvironmentFallback: Boolean, ): F[XRaySpan[F]] = - OptionT(fromKernel(name, kernel, entry)) + OptionT(fromKernel(name, kernel, entry, useEnvironmentFallback)) .getOrElseF(root(name, entry)) def root[F[_]: Concurrent: Clock: Random]( From 4b7be3882512f01ffe44fca1865422e012d14e3e Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 28 Nov 2021 10:23:29 +0100 Subject: [PATCH 065/178] Update cats-core to 2.7.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 6d59ac16..bdf4cad9 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ val scala30Version = "3.1.0" val collectionCompatVersion = "2.4.4" -val catsVersion = "2.6.1" +val catsVersion = "2.7.0" val catsEffectVersion = "3.1.1" // We do `evictionCheck` in CI and don't sweat the Java deps for now. From 6be321634111f4d0d44effffe914855369d57a5c Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 28 Nov 2021 10:24:34 +0100 Subject: [PATCH 066/178] Update cats-effect, cats-effect-kernel to 3.3.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 6d59ac16..f147123a 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.0" val collectionCompatVersion = "2.4.4" val catsVersion = "2.6.1" -val catsEffectVersion = "3.1.1" +val catsEffectVersion = "3.3.0" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From 453a4ec726ec9a241c7348da16661e19d6ab5340 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 30 Nov 2021 06:24:33 +0100 Subject: [PATCH 067/178] Update refined to 0.9.28 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 6d59ac16..90bc424e 100644 --- a/build.sbt +++ b/build.sbt @@ -363,7 +363,7 @@ lazy val examples = project libraryDependencies ++= Seq( "org.typelevel" %% "log4cats-slf4j" % "2.1.1", "org.slf4j" % "slf4j-simple" % "1.7.32", - "eu.timepit" %% "refined" % "0.9.27", + "eu.timepit" %% "refined" % "0.9.28", "is.cir" %% "ciris" % "2.0.1" ) ) From 74d2432414a71fdcf3943fb925766ebbda0e693a Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 30 Nov 2021 17:34:17 +0100 Subject: [PATCH 068/178] Update ip4s-core to 3.1.2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 6d59ac16..bb18381f 100644 --- a/build.sbt +++ b/build.sbt @@ -326,7 +326,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", "co.fs2" %%% "fs2-io" % "3.2.2", - "com.comcast" %%% "ip4s-core" % "3.1.1", + "com.comcast" %%% "ip4s-core" % "3.1.2", "org.scodec" %%% "scodec-bits" % "1.1.29" ) ) From 60de53d7dd923b39d8d09c4254c41b8cc886de19 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 30 Nov 2021 17:34:21 +0100 Subject: [PATCH 069/178] Update scodec-bits to 1.1.30 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 6d59ac16..d9f23f4f 100644 --- a/build.sbt +++ b/build.sbt @@ -327,7 +327,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) "io.circe" %%% "circe-core" % "0.14.1", "co.fs2" %%% "fs2-io" % "3.2.2", "com.comcast" %%% "ip4s-core" % "3.1.1", - "org.scodec" %%% "scodec-bits" % "1.1.29" + "org.scodec" %%% "scodec-bits" % "1.1.30" ) ) .jsSettings( From 146867cee0be0d2b7601cc6157be5b0ac835fedb Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 30 Nov 2021 19:11:08 +0100 Subject: [PATCH 070/178] Update ip4s-core to 3.1.2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index d9f23f4f..a0371094 100644 --- a/build.sbt +++ b/build.sbt @@ -326,7 +326,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", "co.fs2" %%% "fs2-io" % "3.2.2", - "com.comcast" %%% "ip4s-core" % "3.1.1", + "com.comcast" %%% "ip4s-core" % "3.1.2", "org.scodec" %%% "scodec-bits" % "1.1.30" ) ) From f19c6b95fb7c83a05c658cab5a9c8ab34c3cda1c Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 5 Dec 2021 23:09:34 +0100 Subject: [PATCH 071/178] Update munit-cats-effect-3 to 1.0.7 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index a0371094..dc1de0c0 100644 --- a/build.sbt +++ b/build.sbt @@ -55,7 +55,7 @@ lazy val commonSettings = Seq( // Testing libraryDependencies ++= Seq( "org.scalameta" %%% "munit" % "0.7.26" % Test, - "org.typelevel" %%% "munit-cats-effect-3" % "1.0.3" % Test, + "org.typelevel" %%% "munit-cats-effect-3" % "1.0.7" % Test, ), testFrameworks += new TestFramework("munit.Framework"), From 312275452ee3a7f9bc338df39df6ad849cf1a404 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 6 Dec 2021 00:48:17 +0100 Subject: [PATCH 072/178] Update munit to 0.7.29 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index dc1de0c0..a50cc8e5 100644 --- a/build.sbt +++ b/build.sbt @@ -54,7 +54,7 @@ lazy val commonSettings = Seq( // Testing libraryDependencies ++= Seq( - "org.scalameta" %%% "munit" % "0.7.26" % Test, + "org.scalameta" %%% "munit" % "0.7.29" % Test, "org.typelevel" %%% "munit-cats-effect-3" % "1.0.7" % Test, ), testFrameworks += new TestFramework("munit.Framework"), From df5739b4c831cae777f1c68fbdcb31473c2289f9 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 6 Dec 2021 13:05:37 +0100 Subject: [PATCH 073/178] Update ciris to 2.3.1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index a50cc8e5..da5b9f4a 100644 --- a/build.sbt +++ b/build.sbt @@ -364,7 +364,7 @@ lazy val examples = project "org.typelevel" %% "log4cats-slf4j" % "2.1.1", "org.slf4j" % "slf4j-simple" % "1.7.32", "eu.timepit" %% "refined" % "0.9.27", - "is.cir" %% "ciris" % "2.0.1" + "is.cir" %% "ciris" % "2.3.1" ) ) From f645df286e8ff6bee52cda2e98e23fb9ba94468f Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 7 Dec 2021 01:17:20 +0100 Subject: [PATCH 074/178] Update fs2-io to 3.2.3 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index a50cc8e5..81fa8cd0 100644 --- a/build.sbt +++ b/build.sbt @@ -325,7 +325,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", - "co.fs2" %%% "fs2-io" % "3.2.2", + "co.fs2" %%% "fs2-io" % "3.2.3", "com.comcast" %%% "ip4s-core" % "3.1.2", "org.scodec" %%% "scodec-bits" % "1.1.30" ) From dc20828920120f51a43184b3ae5507f6f60b7b73 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 8 Dec 2021 20:22:16 +0100 Subject: [PATCH 075/178] Update http4s-client, http4s-dsl to 0.23.7 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 81fa8cd0..8d4417de 100644 --- a/build.sbt +++ b/build.sbt @@ -413,8 +413,8 @@ lazy val docs = project makeSite := makeSite.dependsOn(mdoc.toTask("")).value, mdocExtraArguments := Seq("--no-link-hygiene"), // paradox handles this libraryDependencies ++= Seq( - "org.http4s" %% "http4s-dsl" % "0.23.0-M1", - "org.http4s" %% "http4s-client" % "0.23.0-M1", + "org.http4s" %% "http4s-dsl" % "0.23.7", + "org.http4s" %% "http4s-client" % "0.23.7", "org.typelevel" %% "log4cats-slf4j" % "2.1.1", "org.slf4j" % "slf4j-simple" % "1.7.32", ) From 3bb29682cf573a6a7956dca055521d5f2c4466be Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 8 Dec 2021 23:43:36 +0100 Subject: [PATCH 076/178] Update dd-trace-api, dd-trace-ot to 0.91.0 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 81fa8cd0..a4bb65ae 100644 --- a/build.sbt +++ b/build.sbt @@ -234,8 +234,8 @@ lazy val datadog = project description := "Datadog bindings for Natchez.", libraryDependencies ++= Seq( "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, - "com.datadoghq" % "dd-trace-ot" % "0.80.0", - "com.datadoghq" % "dd-trace-api" % "0.80.0" + "com.datadoghq" % "dd-trace-ot" % "0.91.0", + "com.datadoghq" % "dd-trace-api" % "0.91.0" ) ) From 4022648ff8a1a7c17013ef2813322ac3842cb2d2 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 10 Dec 2021 22:31:56 +0100 Subject: [PATCH 077/178] Update libhoney-java to 1.3.2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 81fa8cd0..07b138f3 100644 --- a/build.sbt +++ b/build.sbt @@ -149,7 +149,7 @@ lazy val honeycomb = project description := "Honeycomb support for Natchez.", libraryDependencies ++= Seq( "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, - "io.honeycomb.libhoney" % "libhoney-java" % "1.3.1" + "io.honeycomb.libhoney" % "libhoney-java" % "1.3.2" ) ) From d114eeca8add5ed29f2f2187be8edb3c2a67acf9 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 10 Dec 2021 22:32:13 +0100 Subject: [PATCH 078/178] Update sbt to 1.5.6 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 9edb75b7..bb3a9b7d 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.4 +sbt.version=1.5.6 From d041a5a67f89eaf262defa3b4f4a16a0aafd2e5c Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 11 Dec 2021 08:10:18 +0100 Subject: [PATCH 079/178] Update libhoney-java to 1.4.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 07b138f3..f506d369 100644 --- a/build.sbt +++ b/build.sbt @@ -149,7 +149,7 @@ lazy val honeycomb = project description := "Honeycomb support for Natchez.", libraryDependencies ++= Seq( "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, - "io.honeycomb.libhoney" % "libhoney-java" % "1.3.2" + "io.honeycomb.libhoney" % "libhoney-java" % "1.4.0" ) ) From 91287f8ffdc6ce6f827e35c7498676412abebcd3 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 11 Dec 2021 08:10:34 +0100 Subject: [PATCH 080/178] Update sbt-scalajs, scalajs-compiler, ... to 1.8.0 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 31dd41fd..5d0d129b 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,7 +5,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.23") From 77d9d81ae454de66fd57144af905299d5fd37989 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 14 Dec 2021 07:25:53 +0000 Subject: [PATCH 081/178] Fix compile --- modules/examples/src/main/scala/Example.scala | 2 +- modules/examples/src/main/scala/GlobalTracerExample.scala | 2 +- modules/mtl/shared/src/main/scala/LocalTrace.scala | 2 +- modules/mtl/shared/src/main/scala/package.scala | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/examples/src/main/scala/Example.scala b/modules/examples/src/main/scala/Example.scala index a17c4db6..483bf853 100644 --- a/modules/examples/src/main/scala/Example.scala +++ b/modules/examples/src/main/scala/Example.scala @@ -5,7 +5,7 @@ package example import cats._ -import cats.effect._ +import cats.effect.{Trace => _, _} import cats.syntax.all._ import natchez._ import scala.util.Random diff --git a/modules/examples/src/main/scala/GlobalTracerExample.scala b/modules/examples/src/main/scala/GlobalTracerExample.scala index 34988189..b23cc204 100644 --- a/modules/examples/src/main/scala/GlobalTracerExample.scala +++ b/modules/examples/src/main/scala/GlobalTracerExample.scala @@ -6,7 +6,7 @@ package example import cats._ import cats.data.Kleisli -import cats.effect._ +import cats.effect.{Trace => _, _} import cats.syntax.all._ import natchez._ import scala.util.Random diff --git a/modules/mtl/shared/src/main/scala/LocalTrace.scala b/modules/mtl/shared/src/main/scala/LocalTrace.scala index ebfb7ac1..78ced5a2 100644 --- a/modules/mtl/shared/src/main/scala/LocalTrace.scala +++ b/modules/mtl/shared/src/main/scala/LocalTrace.scala @@ -7,7 +7,7 @@ package natchez package mtl import cats.mtl.Local -import cats.effect._ +import cats.effect.MonadCancel import cats.syntax.all._ import java.net.URI diff --git a/modules/mtl/shared/src/main/scala/package.scala b/modules/mtl/shared/src/main/scala/package.scala index ab744a63..c14aa116 100644 --- a/modules/mtl/shared/src/main/scala/package.scala +++ b/modules/mtl/shared/src/main/scala/package.scala @@ -5,7 +5,7 @@ package natchez import cats.mtl.Local -import cats.effect._ +import cats.effect.{Trace => _, _} package object mtl { implicit def natchezMtlTraceForLocal[F[_]]( From 2bd14be72c491586075efe8b0a55fbb7a2928eee Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 14 Dec 2021 07:47:55 +0000 Subject: [PATCH 082/178] Fix conflicting cross version thing --- build.sbt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 397ef5af..2cc32636 100644 --- a/build.sbt +++ b/build.sbt @@ -418,5 +418,6 @@ lazy val docs = project "org.http4s" %% "http4s-client" % "0.23.7", "org.typelevel" %% "log4cats-slf4j" % "2.1.1", "org.slf4j" % "slf4j-simple" % "1.7.32", - ) + ), + excludeDependencies += "org.scala-lang.modules" % "scala-collection-compat_3", // pray this does more good than harm ) From 2e2ad6215a5d63375f9c6e5cd425f56acad90b42 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 14 Dec 2021 07:58:15 +0000 Subject: [PATCH 083/178] Poke ci From 5f66fe88c918599ff67b5214fcf4552e0f186eb0 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 16 Dec 2021 12:06:02 +0100 Subject: [PATCH 084/178] Update sbt to 1.5.7 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index bb3a9b7d..baf5ff3e 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.6 +sbt.version=1.5.7 From 89a8450ee119b90394e14bfea9e0e28a2792477d Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 21 Dec 2021 20:15:21 +0100 Subject: [PATCH 085/178] Update cats-effect, cats-effect-kernel to 3.3.1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 2cc32636..b5eda673 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.0" val collectionCompatVersion = "2.6.0" val catsVersion = "2.7.0" -val catsEffectVersion = "3.3.0" +val catsEffectVersion = "3.3.1" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From 212bd463149c5d487658d0ed8fe3a0dc4e17443c Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 26 Dec 2021 05:17:35 +0100 Subject: [PATCH 086/178] Update fs2-io to 3.2.4 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index b5eda673..cb4f7eb9 100644 --- a/build.sbt +++ b/build.sbt @@ -326,7 +326,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", - "co.fs2" %%% "fs2-io" % "3.2.3", + "co.fs2" %%% "fs2-io" % "3.2.4", "com.comcast" %%% "ip4s-core" % "3.1.2", "org.scodec" %%% "scodec-bits" % "1.1.30" ) From 743d3d3c630b2620ed59085c10d0f2574d951d21 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 31 Dec 2021 04:07:34 +0100 Subject: [PATCH 087/178] Update cats-effect, cats-effect-kernel to 3.3.2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index cb4f7eb9..863ea555 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.0" val collectionCompatVersion = "2.6.0" val catsVersion = "2.7.0" -val catsEffectVersion = "3.3.1" +val catsEffectVersion = "3.3.2" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From 9d796146ca10283c1dadd00da9c35e96fc60e98c Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 1 Jan 2022 05:48:55 +0100 Subject: [PATCH 088/178] Update cats-effect, cats-effect-kernel to 3.3.3 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 863ea555..1295feec 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.0" val collectionCompatVersion = "2.6.0" val catsVersion = "2.7.0" -val catsEffectVersion = "3.3.2" +val catsEffectVersion = "3.3.3" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From 823aab700a611b3a510d0dddd4b9b5ed1e913a96 Mon Sep 17 00:00:00 2001 From: msosnicki Date: Tue, 4 Jan 2022 11:48:48 +0100 Subject: [PATCH 089/178] Setting appropriate error flags and logs in JaegerSpan --- .../jaeger/src/main/scala/JaegerSpan.scala | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/modules/jaeger/src/main/scala/JaegerSpan.scala b/modules/jaeger/src/main/scala/JaegerSpan.scala index 4e7e8a17..d8d93d80 100644 --- a/modules/jaeger/src/main/scala/JaegerSpan.scala +++ b/modules/jaeger/src/main/scala/JaegerSpan.scala @@ -9,6 +9,7 @@ import io.{ opentracing => ot } import cats.data.Nested import cats.effect.Sync import cats.effect.Resource +import cats.effect.Resource.ExitCase import cats.syntax.all._ import io.opentracing.propagation.Format import io.opentracing.propagation.TextMapAdapter @@ -42,13 +43,11 @@ private[jaeger] final case class JaegerSpan[F[_]: Sync]( } def span(name: String): Resource[F,Span[F]] = - Span.putErrorFields( - Resource.make( - Sync[F].delay(tracer.buildSpan(name).asChildOf(span).start))( - s => Sync[F].delay(s.finish) - ).map(JaegerSpan(tracer, _, prefix)) - ) - + Span.putErrorFields { + Resource.makeCase( + Sync[F].delay(tracer.buildSpan(name).asChildOf(span).start).map(JaegerSpan(tracer, _, prefix)) + )(JaegerSpan.finish) + } def traceId: F[Option[String]] = Sync[F].pure { @@ -68,3 +67,24 @@ private[jaeger] final case class JaegerSpan[F[_]: Sync]( } .value } + +private[jaeger] object JaegerSpan { + + def finish[F[_]: Sync]: (JaegerSpan[F], ExitCase) => F[Unit] = (outer, exitCase) => { + val handleExit = exitCase match { + case ExitCase.Errored(ex) => + Sync[F].delay { + outer.span + .setTag(ot.tag.Tags.ERROR.getKey, true) + .log(Map( + ot.log.Fields.EVENT -> ot.tag.Tags.ERROR.getKey, + ot.log.Fields.ERROR_OBJECT -> ex, + ot.log.Fields.MESSAGE -> ex.getMessage, + ot.log.Fields.STACK -> ex.getStackTrace.mkString("\n") + ).asJava) + }.void + case _ => Sync[F].unit + } + handleExit >> Sync[F].delay(outer.span.finish()) + } +} \ No newline at end of file From 0b080833553f651241fbbc1217c6884b1f7e139c Mon Sep 17 00:00:00 2001 From: Maksim Ochenashko Date: Tue, 4 Jan 2022 22:10:41 +0200 Subject: [PATCH 090/178] Update Kernel.scala - cleanup documentation --- modules/core/shared/src/main/scala/Kernel.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/shared/src/main/scala/Kernel.scala b/modules/core/shared/src/main/scala/Kernel.scala index cc564d63..fa5aef60 100644 --- a/modules/core/shared/src/main/scala/Kernel.scala +++ b/modules/core/shared/src/main/scala/Kernel.scala @@ -5,7 +5,7 @@ package natchez /** - * An opaque hunk of data that can we can hand off to another system (in the form of HTTP headers), + * An opaque hunk of data that we can hand off to another system (in the form of HTTP headers), * which can then create new spans as children of this one. By this mechanism we allow our trace * to span remote calls. */ From cdd719ea70ec40f1d343b04106caefc542cb32a8 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 7 Jan 2022 07:07:07 +0100 Subject: [PATCH 091/178] Update grpc-netty to 1.42.2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 1295feec..4be3bb87 100644 --- a/build.sbt +++ b/build.sbt @@ -191,7 +191,7 @@ lazy val lightstepGrpc = project description := "Lightstep gRPC bindings for Natchez.", libraryDependencies ++= Seq( "com.lightstep.tracer" % "tracer-grpc" % "0.30.3", - "io.grpc" % "grpc-netty" % "1.42.1", + "io.grpc" % "grpc-netty" % "1.42.2", "io.netty" % "netty-tcnative-boringssl-static" % "2.0.46.Final" ) ) From 31954a05eb64ee64cf033b05c8e18411b3d2b7d8 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 9 Jan 2022 06:44:01 +0100 Subject: [PATCH 092/178] Update cats-effect, cats-effect-kernel to 3.3.4 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 4be3bb87..8eed9935 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.0" val collectionCompatVersion = "2.6.0" val catsVersion = "2.7.0" -val catsEffectVersion = "3.3.3" +val catsEffectVersion = "3.3.4" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From bfc5851a5ddb0b4f67afdcb61fc428cef98027f3 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 12 Jan 2022 13:33:50 +0100 Subject: [PATCH 093/178] Update ciris to 2.3.2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 8eed9935..b338dfe1 100644 --- a/build.sbt +++ b/build.sbt @@ -365,7 +365,7 @@ lazy val examples = project "org.typelevel" %% "log4cats-slf4j" % "2.1.1", "org.slf4j" % "slf4j-simple" % "1.7.32", "eu.timepit" %% "refined" % "0.9.28", - "is.cir" %% "ciris" % "2.3.1" + "is.cir" %% "ciris" % "2.3.2" ) ) From 1d198fd65165744e9427362611b032cabe4fc8c0 Mon Sep 17 00:00:00 2001 From: Doug Clinton Date: Thu, 13 Jan 2022 10:09:33 +0100 Subject: [PATCH 094/178] Make DDSpan public --- modules/datadog/src/main/scala/DDSpan.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/datadog/src/main/scala/DDSpan.scala b/modules/datadog/src/main/scala/DDSpan.scala index 64670d6b..39d0c607 100644 --- a/modules/datadog/src/main/scala/DDSpan.scala +++ b/modules/datadog/src/main/scala/DDSpan.scala @@ -16,7 +16,7 @@ import natchez.TraceValue.{BooleanValue, NumberValue, StringValue} import scala.jdk.CollectionConverters._ import java.net.URI -private[datadog] final case class DDSpan[F[_]: Sync]( +final case class DDSpan[F[_]: Sync]( tracer: ot.Tracer, span: ot.Span, uriPrefix: Option[URI] From 90d76d51430258f4fe36282fcf9ac0e460f17ece Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 13 Jan 2022 12:18:19 +0100 Subject: [PATCH 095/178] Update scala-library to 2.13.8 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index b338dfe1..70b9bab5 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,5 @@ val scala212Version = "2.12.15" -val scala213Version = "2.13.7" +val scala213Version = "2.13.8" val scala30Version = "3.1.0" val collectionCompatVersion = "2.6.0" From 12e87228bcd1ce7c56c6c27da4951145212ef620 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 13 Jan 2022 21:12:55 +0100 Subject: [PATCH 096/178] Update slf4j-simple to 1.7.33 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 70b9bab5..b63b067f 100644 --- a/build.sbt +++ b/build.sbt @@ -363,7 +363,7 @@ lazy val examples = project scalacOptions -= "-Xfatal-warnings", libraryDependencies ++= Seq( "org.typelevel" %% "log4cats-slf4j" % "2.1.1", - "org.slf4j" % "slf4j-simple" % "1.7.32", + "org.slf4j" % "slf4j-simple" % "1.7.33", "eu.timepit" %% "refined" % "0.9.28", "is.cir" %% "ciris" % "2.3.2" ) @@ -417,7 +417,7 @@ lazy val docs = project "org.http4s" %% "http4s-dsl" % "0.23.7", "org.http4s" %% "http4s-client" % "0.23.7", "org.typelevel" %% "log4cats-slf4j" % "2.1.1", - "org.slf4j" % "slf4j-simple" % "1.7.32", + "org.slf4j" % "slf4j-simple" % "1.7.33", ), excludeDependencies += "org.scala-lang.modules" % "scala-collection-compat_3", // pray this does more good than harm ) From 6010a5c399513183ffd65021c9ff0f351a8f2875 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 25 Jan 2022 12:23:19 +0100 Subject: [PATCH 097/178] Update slf4j-simple to 1.7.35 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index b63b067f..f97ef6de 100644 --- a/build.sbt +++ b/build.sbt @@ -363,7 +363,7 @@ lazy val examples = project scalacOptions -= "-Xfatal-warnings", libraryDependencies ++= Seq( "org.typelevel" %% "log4cats-slf4j" % "2.1.1", - "org.slf4j" % "slf4j-simple" % "1.7.33", + "org.slf4j" % "slf4j-simple" % "1.7.35", "eu.timepit" %% "refined" % "0.9.28", "is.cir" %% "ciris" % "2.3.2" ) @@ -417,7 +417,7 @@ lazy val docs = project "org.http4s" %% "http4s-dsl" % "0.23.7", "org.http4s" %% "http4s-client" % "0.23.7", "org.typelevel" %% "log4cats-slf4j" % "2.1.1", - "org.slf4j" % "slf4j-simple" % "1.7.33", + "org.slf4j" % "slf4j-simple" % "1.7.35", ), excludeDependencies += "org.scala-lang.modules" % "scala-collection-compat_3", // pray this does more good than harm ) From 499075f0a875b011c4fc8369ed5b7c8fc32556c4 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 29 Jan 2022 09:41:28 +0100 Subject: [PATCH 098/178] Update cats-effect, cats-effect-kernel to 3.3.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index f97ef6de..4c61240f 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.0" val collectionCompatVersion = "2.6.0" val catsVersion = "2.7.0" -val catsEffectVersion = "3.3.4" +val catsEffectVersion = "3.3.5" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From 52ddd6ec12468c08d9d93df24434e9b3a3b49bb0 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 2 Feb 2022 03:48:37 +0100 Subject: [PATCH 099/178] Update scala3-library, ... to 3.1.1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 4c61240f..a5894acc 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ val scala212Version = "2.12.15" val scala213Version = "2.13.8" -val scala30Version = "3.1.0" +val scala30Version = "3.1.1" val collectionCompatVersion = "2.6.0" From 281327d4b468e16ac8140fcdeee6fc0ab25c91f9 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 2 Feb 2022 11:49:51 +0100 Subject: [PATCH 100/178] Update libhoney-java to 1.4.1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index a5894acc..90fbf01c 100644 --- a/build.sbt +++ b/build.sbt @@ -150,7 +150,7 @@ lazy val honeycomb = project description := "Honeycomb support for Natchez.", libraryDependencies ++= Seq( "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, - "io.honeycomb.libhoney" % "libhoney-java" % "1.4.0" + "io.honeycomb.libhoney" % "libhoney-java" % "1.4.1" ) ) From e094e26384a396e4b9ef1260e1e565a2f9552738 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 7 Feb 2022 11:05:06 +0100 Subject: [PATCH 101/178] Update sbt-header to 5.6.5 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index f8fe733b..ad0dbb9a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") +addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.5") addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") From 34f0f678090959b62f28fcc7cf2e81d11ec9bdc7 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 8 Feb 2022 19:40:42 +0100 Subject: [PATCH 102/178] Update slf4j-simple to 1.7.36 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 90fbf01c..968613d7 100644 --- a/build.sbt +++ b/build.sbt @@ -363,7 +363,7 @@ lazy val examples = project scalacOptions -= "-Xfatal-warnings", libraryDependencies ++= Seq( "org.typelevel" %% "log4cats-slf4j" % "2.1.1", - "org.slf4j" % "slf4j-simple" % "1.7.35", + "org.slf4j" % "slf4j-simple" % "1.7.36", "eu.timepit" %% "refined" % "0.9.28", "is.cir" %% "ciris" % "2.3.2" ) @@ -417,7 +417,7 @@ lazy val docs = project "org.http4s" %% "http4s-dsl" % "0.23.7", "org.http4s" %% "http4s-client" % "0.23.7", "org.typelevel" %% "log4cats-slf4j" % "2.1.1", - "org.slf4j" % "slf4j-simple" % "1.7.35", + "org.slf4j" % "slf4j-simple" % "1.7.36", ), excludeDependencies += "org.scala-lang.modules" % "scala-collection-compat_3", // pray this does more good than harm ) From 598b36fbc66b8801556f2824a1b4758841ff2187 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 19 Feb 2022 21:18:30 +0100 Subject: [PATCH 103/178] Update fs2-io to 3.2.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 968613d7..ad85db87 100644 --- a/build.sbt +++ b/build.sbt @@ -326,7 +326,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", - "co.fs2" %%% "fs2-io" % "3.2.4", + "co.fs2" %%% "fs2-io" % "3.2.5", "com.comcast" %%% "ip4s-core" % "3.1.2", "org.scodec" %%% "scodec-bits" % "1.1.30" ) From 8d76cf791472d2ee82a4ed1b446dc5c42640692c Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 28 Feb 2022 08:29:47 +0100 Subject: [PATCH 104/178] Update cats-effect, cats-effect-kernel to 3.3.6 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index ad85db87..1fff8a94 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.1" val collectionCompatVersion = "2.6.0" val catsVersion = "2.7.0" -val catsEffectVersion = "3.3.5" +val catsEffectVersion = "3.3.6" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From 63cf9735479623980081cf4fc37866c2557d6f32 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 8 Mar 2022 14:59:27 +0100 Subject: [PATCH 105/178] Update cats-effect, cats-effect-kernel to 3.3.7 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 1fff8a94..0de9c92d 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.1" val collectionCompatVersion = "2.6.0" val catsVersion = "2.7.0" -val catsEffectVersion = "3.3.6" +val catsEffectVersion = "3.3.7" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From e61094f94acecdeef8cebec271a3492c6f1f2910 Mon Sep 17 00:00:00 2001 From: Antoine Comte Date: Thu, 10 Mar 2022 15:25:56 +0100 Subject: [PATCH 106/178] Fix example in documentation There seems to be bad copy/paste here. The `parent :Span[F]` parameter should not be there IMO --- modules/docs/src/main/paradox/reference/spans.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/docs/src/main/paradox/reference/spans.md b/modules/docs/src/main/paradox/reference/spans.md index aaaac026..761bad1e 100644 --- a/modules/docs/src/main/paradox/reference/spans.md +++ b/modules/docs/src/main/paradox/reference/spans.md @@ -45,7 +45,7 @@ This approach might make sense if you're using a concrete effect type with no "r A nicer way to pass the current span around is to use the `Trace` constraint, which ensures that there is always a current span. With this strategy you never have see `Span` reference at all, but instead use the `Trace` instance directly. ```scala mdoc -def wibble[F[_]: Trace: Monad](name: String, age: Int, parent: Span[F]): F[Unit] = +def wibble[F[_]: Trace: Monad](name: String, age: Int): F[Unit] = Trace[F].span("wibble") { for { _ <- Trace[F].put("name" -> name, "age" -> age) From 017726c68a7133b5810c7f25e7adbc394977f984 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 19 Mar 2022 22:20:24 +0100 Subject: [PATCH 107/178] Update cats-effect, cats-effect-kernel to 3.3.8 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 0de9c92d..9c47bf5d 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.1" val collectionCompatVersion = "2.6.0" val catsVersion = "2.7.0" -val catsEffectVersion = "3.3.7" +val catsEffectVersion = "3.3.8" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From 6ddfbf772e0b762abf06c6f9447bc630d7b1e302 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 25 Mar 2022 04:51:30 +0100 Subject: [PATCH 108/178] Update cats-effect, cats-effect-kernel to 3.3.9 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 9c47bf5d..cb001fc6 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.1" val collectionCompatVersion = "2.6.0" val catsVersion = "2.7.0" -val catsEffectVersion = "3.3.8" +val catsEffectVersion = "3.3.9" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From 06a5d76e676c604f17ef7e1db052e58ed69d3f71 Mon Sep 17 00:00:00 2001 From: Erlend Hamnaberg Date: Fri, 25 Mar 2022 12:54:22 +0100 Subject: [PATCH 109/178] Add OpenTelemetry module --- build.sbt | 15 ++ modules/opentelemetry/README.md | 60 +++++++ .../natchez/opentelemetry/OpenTelemetry.scala | 30 ++++ .../opentelemetry/OpenTelemetrySpan.scala | 160 ++++++++++++++++++ project/build.properties | 2 +- 5 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 modules/opentelemetry/README.md create mode 100644 modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetry.scala create mode 100644 modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetrySpan.scala diff --git a/build.sbt b/build.sbt index cb001fc6..4083ecea 100644 --- a/build.sbt +++ b/build.sbt @@ -224,6 +224,21 @@ lazy val opentracing = project ) ) +lazy val opentelemetry = project + .in(file("modules/opentelemetry")) + .dependsOn(coreJVM) + .enablePlugins(AutomateHeaderPlugin) + .settings(commonSettings) + .settings( + name := "natchez-opentelemetry", + description := "Base OpenTelemetry Utilities for Natchez", + libraryDependencies ++= Seq( + "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, + "io.opentelemetry" % "opentelemetry-sdk" % "1.12.0" + ) + ) + + lazy val datadog = project .in(file("modules/datadog")) diff --git a/modules/opentelemetry/README.md b/modules/opentelemetry/README.md new file mode 100644 index 00000000..9cf7a90f --- /dev/null +++ b/modules/opentelemetry/README.md @@ -0,0 +1,60 @@ +# OpenTelemetry + +OpenTelemetry is capable of exporting to different collector types. Exporters are added registered globally against a +singleton registry. There is nothing stopping someone registering a new exporter outside of a side effect, so it is up +to the user whether to do so inside the effects system or not. + +The recommended approach for registering exporters is to use a resource. +The snippet below shows how this may be done +for the Google Cloud Trace exporter implementation: + +The google cloud trace export can be found here: +```scala +libraryDependencies ++= Seq( + "com.google.cloud.opentelemetry" % "exporter-trace" % "0.20.0", + "com.google.cloud" % "google-cloud-trace" % "2.1.9" +) +``` + +```scala +import cats.effect.{Resource, Sync} +import io.opentelemetry.api.GlobalOpenTelemetry +import natchez.opentelemetry.OpenTelemetry +import io.opentelemetry.sdk.OpenTelemetrySdk +import io.opentelemetry.sdk.trace.SdkTracerProvider +import io.opentelemetry.sdk.trace.`export`.BatchSpanProcessor +import com.google.cloud.opentelemetry.trace.{TraceConfiguration, TraceExporter} +import natchez.opentelemetry.OpenTelemetry + +def entrypoint[F[_] : Sync](projectId: String)(configure: TraceConfiguration.Builder => TraceConfiguration.Builder): Resource[F, EntryPoint[F]] = + Resource + .make( + Sync[F].delay( + OpenTelemetrySdk + .builder() + .setTracerProvider( + SdkTracerProvider + .builder() + .addSpanProcessor( + BatchSpanProcessor + .builder( + TraceExporter + .createWithConfiguration( + configure(TraceConfiguration.builder().setProjectId(projectId)).build() + ) + ) + .build() + ) + .build() + ) + .buildAndRegisterGlobal() + ) + )(sdk => + Sync[F].blocking { + sdk.getSdkTracerProvider.close() + GlobalOpenTelemetry.set(null) + } + ) + .flatMap(sdk => Resource.eval(OpenTelemetry.entryPointForSdk[F](sdk))) + +``` \ No newline at end of file diff --git a/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetry.scala b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetry.scala new file mode 100644 index 00000000..39e8ef5c --- /dev/null +++ b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetry.scala @@ -0,0 +1,30 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez.opentelemetry + +import cats.syntax.all._ +import cats.effect.{Resource, Sync} +import io.opentelemetry.sdk.OpenTelemetrySdk +import natchez.{EntryPoint, Kernel, Span} + +object OpenTelemetry { + def entryPointForSdk[F[_] : Sync](sdk: OpenTelemetrySdk): F[EntryPoint[F]] = + Sync[F] + .delay(sdk.getTracer("natchez")) + .map { t => + new EntryPoint[F] { + def continue(name: String, kernel: Kernel): Resource[F, Span[F]] = + Resource.makeCase(OpenTelemetrySpan.fromKernel(sdk, t, name, kernel))(OpenTelemetrySpan.finish).widen + + def root(name: String): Resource[F, Span[F]] = + Resource.makeCase(OpenTelemetrySpan.root(sdk, t, name))(OpenTelemetrySpan.finish).widen + + def continueOrElseRoot(name: String, kernel: Kernel): Resource[F, Span[F]] = + Resource + .makeCase(OpenTelemetrySpan.fromKernelOrElseRoot(sdk, t, name, kernel))(OpenTelemetrySpan.finish) + .widen + } + } +} diff --git a/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetrySpan.scala b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetrySpan.scala new file mode 100644 index 00000000..e361bb11 --- /dev/null +++ b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetrySpan.scala @@ -0,0 +1,160 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez.opentelemetry + + +import cats.effect.{Resource, Sync} +import cats.effect.kernel.Resource.ExitCase +import cats.effect.kernel.Resource.ExitCase.{Canceled, Errored, Succeeded} +import cats.syntax.all._ +import io.opentelemetry.api.trace.StatusCode +import io.opentelemetry.context.propagation.{TextMapGetter, TextMapSetter} +import io.opentelemetry.context.Context + +import java.lang +import io.opentelemetry.api.trace.{Tracer, Span => TSpan} +import io.opentelemetry.sdk.OpenTelemetrySdk +import natchez.{Fields, Kernel, Span, TraceValue} +import natchez.TraceValue.{BooleanValue, NumberValue, StringValue} + +import java.net.URI +import scala.collection.mutable + +private[opentelemetry] final case class OpenTelemetrySpan[F[_] : Sync](sdk: OpenTelemetrySdk, tracer: Tracer, span: TSpan) extends Span[F] { + + import OpenTelemetrySpan._ + + override def put(fields: (String, TraceValue)*): F[Unit] = + fields.toList.traverse_ { + case (k, StringValue(v)) => + val safeString = + if (v == null) "null" else v + Sync[F].delay(span.setAttribute(k, safeString)) + case (k, NumberValue(v)) => + Sync[F].delay(span.setAttribute(k, v.doubleValue())) + case (k, BooleanValue(v)) => + Sync[F].delay(span.setAttribute(k, v)) + } + + override def kernel: F[Kernel] = + Sync[F].delay { + val headers: mutable.Map[String, String] = mutable.Map.empty[String, String] + sdk.getPropagators.getTextMapPropagator.inject(Context.current(), headers, spanContextSetter) + Kernel(headers.toMap) + } + + override def span(name: String): Resource[F, Span[F]] = + Span.putErrorFields(Resource.makeCase(OpenTelemetrySpan.child(this, name))(OpenTelemetrySpan.finish).widen) + + def traceId: F[Option[String]] = + Sync[F].pure { + val rawId = span.getSpanContext.getTraceId + if (rawId.nonEmpty) rawId.some else none + } + + def spanId: F[Option[String]] = + Sync[F].pure { + val rawId = span.getSpanContext.getSpanId + if (rawId.nonEmpty) rawId.some else none + } + + def traceUri: F[Option[URI]] = none[URI].pure[F] + +} + +private[opentelemetry] object OpenTelemetrySpan { + def finish[F[_] : Sync]: (OpenTelemetrySpan[F], ExitCase) => F[Unit] = { (outer, exitCase) => + for { + // collect error details, if any + _ <- + exitCase.some + .collect { + case Errored(t: Fields) => t.fields.toList + } + .traverse(outer.put) + _ <- Sync[F].delay { + exitCase match { + case Succeeded => outer.span.setStatus(StatusCode.OK) + case Canceled => outer.span.setStatus(StatusCode.UNSET) + case Errored(ex) => + outer.span.setStatus(StatusCode.ERROR, ex.getMessage) + outer.span.recordException(ex) + } + } + _ <- Sync[F].delay(outer.span.end()) + } yield () + } + + def child[F[_] : Sync]( + parent: OpenTelemetrySpan[F], + name: String + ): F[OpenTelemetrySpan[F]] = + Sync[F] + .delay( + parent.tracer + .spanBuilder(name) + .setParent(Context.current()) + .startSpan() + ) + .map(OpenTelemetrySpan(parent.sdk, parent.tracer, _)) + + def root[F[_] : Sync]( + sdk: OpenTelemetrySdk, + tracer: Tracer, + name: String + ): F[OpenTelemetrySpan[F]] = + Sync[F] + .delay( + tracer + .spanBuilder(name) + .startSpan() + ) + .map(OpenTelemetrySpan(sdk, tracer, _)) + + def fromKernel[F[_] : Sync]( + sdk: OpenTelemetrySdk, + tracer: Tracer, + name: String, + kernel: Kernel + ): F[OpenTelemetrySpan[F]] = + Sync[F] + .delay { + val ctx = sdk.getPropagators.getTextMapPropagator + .extract(Context.current(), kernel, spanContextGetter) + tracer.spanBuilder(name).setParent(ctx).startSpan() + } + .map(OpenTelemetrySpan(sdk, tracer, _)) + + def fromKernelOrElseRoot[F[_]]( + sdk: OpenTelemetrySdk, + tracer: Tracer, + name: String, + kernel: Kernel + )(implicit ev: Sync[F]): F[OpenTelemetrySpan[F]] = + fromKernel(sdk, tracer, name, kernel).recoverWith { + case _: NoSuchElementException => + root(sdk, tracer, name) // means headers are incomplete or invalid + case _: NullPointerException => + root(sdk, tracer, name) // means headers are incomplete or invalid + } + + private val spanContextGetter: TextMapGetter[Kernel] = new TextMapGetter[Kernel] { + + import scala.jdk.CollectionConverters._ + + override def keys(carrier: Kernel): lang.Iterable[String] = carrier.toHeaders.keys.asJava + + override def get(carrier: Kernel, key: String): String = + carrier.toHeaders(key) + } + + private val spanContextSetter = new TextMapSetter[mutable.Map[String, String]] { + override def set(carrier: mutable.Map[String, String], key: String, value: String): Unit = { + carrier.put(key, value) + () + } + } +} + diff --git a/project/build.properties b/project/build.properties index baf5ff3e..c8fcab54 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.7 +sbt.version=1.6.2 From cb9326ff9af5ad3c3bf96f9bbd44e6f4646ad5eb Mon Sep 17 00:00:00 2001 From: Erlend Hamnaberg Date: Mon, 28 Mar 2022 16:58:50 +0200 Subject: [PATCH 110/178] Update example in README.md --- modules/opentelemetry/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/opentelemetry/README.md b/modules/opentelemetry/README.md index 9cf7a90f..3e152239 100644 --- a/modules/opentelemetry/README.md +++ b/modules/opentelemetry/README.md @@ -47,12 +47,11 @@ def entrypoint[F[_] : Sync](projectId: String)(configure: TraceConfiguration.Bui ) .build() ) - .buildAndRegisterGlobal() + .build() ) )(sdk => Sync[F].blocking { sdk.getSdkTracerProvider.close() - GlobalOpenTelemetry.set(null) } ) .flatMap(sdk => Resource.eval(OpenTelemetry.entryPointForSdk[F](sdk))) From 08ad907c076292c76a8613d65b036b7c93b9ff7e Mon Sep 17 00:00:00 2001 From: Erlend Hamnaberg Date: Tue, 29 Mar 2022 13:21:51 +0200 Subject: [PATCH 111/178] include parent span in child --- .../main/scala/natchez/opentelemetry/OpenTelemetrySpan.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetrySpan.scala b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetrySpan.scala index e361bb11..0bbe847f 100644 --- a/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetrySpan.scala +++ b/modules/opentelemetry/src/main/scala/natchez/opentelemetry/OpenTelemetrySpan.scala @@ -95,7 +95,7 @@ private[opentelemetry] object OpenTelemetrySpan { .delay( parent.tracer .spanBuilder(name) - .setParent(Context.current()) + .setParent(Context.current().`with`(parent.span)) .startSpan() ) .map(OpenTelemetrySpan(parent.sdk, parent.tracer, _)) From dded22135697658e10aaca84493c53632c1c5e81 Mon Sep 17 00:00:00 2001 From: Erlend Hamnaberg Date: Tue, 29 Mar 2022 19:57:16 +0200 Subject: [PATCH 112/178] Add TextMapPropagators to example --- modules/opentelemetry/README.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/opentelemetry/README.md b/modules/opentelemetry/README.md index 3e152239..3ee922cb 100644 --- a/modules/opentelemetry/README.md +++ b/modules/opentelemetry/README.md @@ -4,15 +4,15 @@ OpenTelemetry is capable of exporting to different collector types. Exporters ar singleton registry. There is nothing stopping someone registering a new exporter outside of a side effect, so it is up to the user whether to do so inside the effects system or not. -The recommended approach for registering exporters is to use a resource. -The snippet below shows how this may be done +The recommended approach for registering exporters is to use a resource. The snippet below shows how this may be done for the Google Cloud Trace exporter implementation: The google cloud trace export can be found here: + ```scala libraryDependencies ++= Seq( - "com.google.cloud.opentelemetry" % "exporter-trace" % "0.20.0", - "com.google.cloud" % "google-cloud-trace" % "2.1.9" + "com.google.cloud.opentelemetry" % "exporter-trace" % "0.20.0", + "com.google.cloud" % "google-cloud-trace" % "2.1.9" ) ``` @@ -23,6 +23,9 @@ import natchez.opentelemetry.OpenTelemetry import io.opentelemetry.sdk.OpenTelemetrySdk import io.opentelemetry.sdk.trace.SdkTracerProvider import io.opentelemetry.sdk.trace.`export`.BatchSpanProcessor +import io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator +import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator +import io.opentelemetry.context.propagation.{ContextPropagators, TextMapPropagator} import com.google.cloud.opentelemetry.trace.{TraceConfiguration, TraceExporter} import natchez.opentelemetry.OpenTelemetry @@ -46,8 +49,11 @@ def entrypoint[F[_] : Sync](projectId: String)(configure: TraceConfiguration.Bui .build() ) .build() + ).setPropagators( + ContextPropagators.create( + TextMapPropagator.composite(W3CTraceContextPropagator.getInstance(), W3CBaggagePropagator.getInstance()) ) - .build() + ).build() ) )(sdk => Sync[F].blocking { From 191724906b3181c31c8e42f6762d1cd9d6c82554 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 30 Mar 2022 01:11:12 +0200 Subject: [PATCH 113/178] Update fs2-io to 3.2.6 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index cb001fc6..fdcd8464 100644 --- a/build.sbt +++ b/build.sbt @@ -326,7 +326,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", - "co.fs2" %%% "fs2-io" % "3.2.5", + "co.fs2" %%% "fs2-io" % "3.2.6", "com.comcast" %%% "ip4s-core" % "3.1.2", "org.scodec" %%% "scodec-bits" % "1.1.30" ) From 2cb326f7fdcc73dca27f4b92de48d2c04e5fe59b Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 30 Mar 2022 15:19:39 +0200 Subject: [PATCH 114/178] Update fs2-io to 3.2.7 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index fdcd8464..476da2dc 100644 --- a/build.sbt +++ b/build.sbt @@ -326,7 +326,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", - "co.fs2" %%% "fs2-io" % "3.2.6", + "co.fs2" %%% "fs2-io" % "3.2.7", "com.comcast" %%% "ip4s-core" % "3.1.2", "org.scodec" %%% "scodec-bits" % "1.1.30" ) From 1c6c6d19aa39806ff646b239a187e9709e5af3f3 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 4 Apr 2022 03:04:16 +0200 Subject: [PATCH 115/178] Update cats-effect, cats-effect-kernel to 3.3.10 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 476da2dc..76d2ff13 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.1" val collectionCompatVersion = "2.6.0" val catsVersion = "2.7.0" -val catsEffectVersion = "3.3.9" +val catsEffectVersion = "3.3.10" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From 0dc823935ead5f7e6cabd69067b0f2785f6f2a4a Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 6 Apr 2022 02:38:35 +0200 Subject: [PATCH 116/178] Update cats-effect, cats-effect-kernel to 3.3.11 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 76d2ff13..bc0b8e9c 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.1" val collectionCompatVersion = "2.6.0" val catsVersion = "2.7.0" -val catsEffectVersion = "3.3.10" +val catsEffectVersion = "3.3.11" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From 5e5b2b71aacab39351466e72dffd824fb6b160ae Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 12 Apr 2022 20:35:28 +0200 Subject: [PATCH 117/178] Update scala3-library, ... to 3.1.2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index bc0b8e9c..e68dad82 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ val scala212Version = "2.12.15" val scala213Version = "2.13.8" -val scala30Version = "3.1.1" +val scala30Version = "3.1.2" val collectionCompatVersion = "2.6.0" From 8a83ad11d431f7486c7bf179dba609bc6115ef37 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 27 Apr 2022 00:57:13 +0200 Subject: [PATCH 118/178] Update scodec-bits to 1.1.31 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index e68dad82..5e6b54da 100644 --- a/build.sbt +++ b/build.sbt @@ -328,7 +328,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) "io.circe" %%% "circe-core" % "0.14.1", "co.fs2" %%% "fs2-io" % "3.2.7", "com.comcast" %%% "ip4s-core" % "3.1.2", - "org.scodec" %%% "scodec-bits" % "1.1.30" + "org.scodec" %%% "scodec-bits" % "1.1.31" ) ) .jsSettings( From edcda651edd07ef7c403b6ca64be0a4a93248603 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 29 Apr 2022 19:14:29 +0200 Subject: [PATCH 119/178] Update opencensus-exporter-trace-ocagent to 0.31.1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 5e6b54da..5b223066 100644 --- a/build.sbt +++ b/build.sbt @@ -163,7 +163,7 @@ lazy val opencensus = project name := "natchez-opencensus", description := "Opencensus support for Natchez.", libraryDependencies ++= Seq( - "io.opencensus" % "opencensus-exporter-trace-ocagent" % "0.28.3" + "io.opencensus" % "opencensus-exporter-trace-ocagent" % "0.31.1" ) ) From 08c71b15fba63d92b5b960c735a224e2aeb95666 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 10 May 2022 16:11:28 +0200 Subject: [PATCH 120/178] Update refined to 0.9.29 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 5e6b54da..ee59ecd2 100644 --- a/build.sbt +++ b/build.sbt @@ -364,7 +364,7 @@ lazy val examples = project libraryDependencies ++= Seq( "org.typelevel" %% "log4cats-slf4j" % "2.1.1", "org.slf4j" % "slf4j-simple" % "1.7.36", - "eu.timepit" %% "refined" % "0.9.28", + "eu.timepit" %% "refined" % "0.9.29", "is.cir" %% "ciris" % "2.3.2" ) ) From 32377b4e701615a693f738a1b99632c9d9ed48aa Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 17 May 2022 06:36:03 +0200 Subject: [PATCH 121/178] Update ip4s-core to 3.1.3 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 5e6b54da..f0f75ec2 100644 --- a/build.sbt +++ b/build.sbt @@ -327,7 +327,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", "co.fs2" %%% "fs2-io" % "3.2.7", - "com.comcast" %%% "ip4s-core" % "3.1.2", + "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" ) ) From c1e470dcafb65016da0442ed7d3fd937000f1dbd Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 20 May 2022 07:25:39 +0200 Subject: [PATCH 122/178] Update circe-core to 0.14.2 --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index f0f75ec2..8e63fc7f 100644 --- a/build.sbt +++ b/build.sbt @@ -249,7 +249,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", + "io.circe" %%% "circe-core" % "0.14.2", "org.typelevel" %%% "log4cats-core" % "2.1.1", "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, ) @@ -271,7 +271,7 @@ lazy val newrelic = project name := "newrelic", description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.14.1", + "io.circe" %% "circe-core" % "0.14.2", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.12.0", @@ -325,7 +325,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) name := "natchez-xray", description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", + "io.circe" %%% "circe-core" % "0.14.2", "co.fs2" %%% "fs2-io" % "3.2.7", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" From 5bb0f2b2a7e9d91a3a873370718f6c0d584d5958 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 21 May 2022 07:18:20 +0200 Subject: [PATCH 123/178] Update cats-effect, cats-effect-kernel to 3.3.12 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index f0f75ec2..91162c48 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.2" val collectionCompatVersion = "2.6.0" val catsVersion = "2.7.0" -val catsEffectVersion = "3.3.11" +val catsEffectVersion = "3.3.12" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From bcef34dbaba2667cc59f7abd80bed95d105f4b87 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 7 Jul 2022 03:01:49 +0000 Subject: [PATCH 124/178] Update fs2-io to 3.2.9 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 91162c48..f1e8a91e 100644 --- a/build.sbt +++ b/build.sbt @@ -326,7 +326,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", - "co.fs2" %%% "fs2-io" % "3.2.7", + "co.fs2" %%% "fs2-io" % "3.2.9", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" ) From 47669524989f3fe9f5ef916bcc632806f14d9a1d Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 7 Jul 2022 03:02:14 +0000 Subject: [PATCH 125/178] Update paradox-theme-generic, sbt-paradox to 0.10.2 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index ad0dbb9a..c436d3d0 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.5") -addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2") +addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.10.2") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") From 059e037e6b13abcc9a42c8ad6e3e8006a9159c8b Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 7 Jul 2022 03:02:31 +0000 Subject: [PATCH 126/178] Update sbt-updates to 0.6.3 --- project/plugins.sbt | 2 +- project/project/plugins.sbt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index ad0dbb9a..f0ffc999 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -4,7 +4,7 @@ addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.0") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.3") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") diff --git a/project/project/plugins.sbt b/project/project/plugins.sbt index fbb205c7..95f09fd4 100644 --- a/project/project/plugins.sbt +++ b/project/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.0") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.3") From b4bafc946853f283ea29e782e0c0a287fa8da30e Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 7 Jul 2022 03:02:38 +0000 Subject: [PATCH 127/178] Update scala-java-time to 2.4.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 91162c48..4eb49088 100644 --- a/build.sbt +++ b/build.sbt @@ -251,7 +251,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", "org.typelevel" %%% "log4cats-core" % "2.1.1", - "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, + "io.github.cquiroz" %%% "scala-java-time" % "2.4.0" % Test, ) ) lazy val logJVM = log.jvm.dependsOn(coreJVM) From 76283eec81b8d50be6746605bf3494481e6c8008 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 7 Jul 2022 03:03:04 +0000 Subject: [PATCH 128/178] Update jaeger-client to 1.8.1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 91162c48..a7dc856b 100644 --- a/build.sbt +++ b/build.sbt @@ -136,7 +136,7 @@ lazy val jaeger = project description := "Jaeger support for Natchez.", libraryDependencies ++= Seq( "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, - "io.jaegertracing" % "jaeger-client" % "1.6.0", + "io.jaegertracing" % "jaeger-client" % "1.8.1", ) ) From 0c62bb2bb1c7eefb1be9a9ed1513794dafaf0d6b Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 7 Jul 2022 03:03:47 +0000 Subject: [PATCH 129/178] Update scala-library to 2.12.16 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 91162c48..528518b2 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -val scala212Version = "2.12.15" +val scala212Version = "2.12.16" val scala213Version = "2.13.8" val scala30Version = "3.1.2" From 7d0995386ae08c5f8398e405d36031320d5016eb Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 7 Jul 2022 03:03:51 +0000 Subject: [PATCH 130/178] Update scala3-library, ... to 3.1.3 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 91162c48..d5a99d14 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ val scala212Version = "2.12.15" val scala213Version = "2.13.8" -val scala30Version = "3.1.2" +val scala30Version = "3.1.3" val collectionCompatVersion = "2.6.0" From af283e31a8bc6fb2c8879738e557115e8cedb166 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 7 Jul 2022 03:03:55 +0000 Subject: [PATCH 131/178] Update scodec-bits to 1.1.34 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 91162c48..58cc0ff9 100644 --- a/build.sbt +++ b/build.sbt @@ -328,7 +328,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) "io.circe" %%% "circe-core" % "0.14.1", "co.fs2" %%% "fs2-io" % "3.2.7", "com.comcast" %%% "ip4s-core" % "3.1.3", - "org.scodec" %%% "scodec-bits" % "1.1.31" + "org.scodec" %%% "scodec-bits" % "1.1.34" ) ) .jsSettings( From 4cb590fd68edc1b0b648ebca11a320712de91abc Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 7 Jul 2022 03:03:58 +0000 Subject: [PATCH 132/178] Update cats-core to 2.8.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 91162c48..4aecf9d7 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ val scala30Version = "3.1.2" val collectionCompatVersion = "2.6.0" -val catsVersion = "2.7.0" +val catsVersion = "2.8.0" val catsEffectVersion = "3.3.12" // We do `evictionCheck` in CI and don't sweat the Java deps for now. From 6814590d64c67f86c3152cd6099766c13f908823 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 7 Jul 2022 03:04:12 +0000 Subject: [PATCH 133/178] Update cats-mtl to 1.3.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 91162c48..b4e9167e 100644 --- a/build.sbt +++ b/build.sbt @@ -287,7 +287,7 @@ lazy val mtl = crossProject(JSPlatform, JVMPlatform) name := "natchez-mtl", description := "cats-mtl bindings for Natchez.", libraryDependencies ++= Seq( - "org.typelevel" %%% "cats-mtl" % "1.2.1", + "org.typelevel" %%% "cats-mtl" % "1.3.0", ) ) From 68e96f5579cb09a7280ab6fa5b5946ed38288488 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 8 Jul 2022 07:59:46 +0000 Subject: [PATCH 134/178] Revert commit(s) c1e470d --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 8e63fc7f..f0f75ec2 100644 --- a/build.sbt +++ b/build.sbt @@ -249,7 +249,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.2", + "io.circe" %%% "circe-core" % "0.14.1", "org.typelevel" %%% "log4cats-core" % "2.1.1", "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, ) @@ -271,7 +271,7 @@ lazy val newrelic = project name := "newrelic", description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.14.2", + "io.circe" %% "circe-core" % "0.14.1", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.12.0", @@ -325,7 +325,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) name := "natchez-xray", description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.2", + "io.circe" %%% "circe-core" % "0.14.1", "co.fs2" %%% "fs2-io" % "3.2.7", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" From dc0da7a9576e1639f3c65ffee0f74cb36ae3d3f8 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 8 Jul 2022 07:59:47 +0000 Subject: [PATCH 135/178] Update circe-core to 0.14.2 --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index f1e8a91e..3eb8b7ae 100644 --- a/build.sbt +++ b/build.sbt @@ -249,7 +249,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", + "io.circe" %%% "circe-core" % "0.14.2", "org.typelevel" %%% "log4cats-core" % "2.1.1", "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, ) @@ -271,7 +271,7 @@ lazy val newrelic = project name := "newrelic", description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.14.1", + "io.circe" %% "circe-core" % "0.14.2", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.12.0", @@ -325,7 +325,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) name := "natchez-xray", description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", + "io.circe" %%% "circe-core" % "0.14.2", "co.fs2" %%% "fs2-io" % "3.2.9", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" From 05aa35c8f7f0f04b77ae6fb85f5979c33ca21234 Mon Sep 17 00:00:00 2001 From: Massimo Siani Date: Sun, 10 Jul 2022 21:25:09 +0200 Subject: [PATCH 136/178] add long to the allowed values --- modules/core/shared/src/main/scala/TraceValue.scala | 3 ++- .../core/shared/src/test/scala/TraceValueTest.scala | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 modules/core/shared/src/test/scala/TraceValueTest.scala diff --git a/modules/core/shared/src/main/scala/TraceValue.scala b/modules/core/shared/src/main/scala/TraceValue.scala index 0577180b..ff392ae4 100644 --- a/modules/core/shared/src/main/scala/TraceValue.scala +++ b/modules/core/shared/src/main/scala/TraceValue.scala @@ -13,9 +13,10 @@ object TraceValue { case class StringValue(value: String) extends TraceValue case class BooleanValue(value: Boolean) extends TraceValue case class NumberValue(value: Number) extends TraceValue - + implicit def stringToTraceValue(value: String): TraceValue = StringValue(value) implicit def boolToTraceValue(value: Boolean): TraceValue = BooleanValue(value) implicit def intToTraceValue(value: Int): TraceValue = NumberValue(value) + implicit def longToTraceValue(value: Long): TraceValue = NumberValue(value) } \ No newline at end of file diff --git a/modules/core/shared/src/test/scala/TraceValueTest.scala b/modules/core/shared/src/test/scala/TraceValueTest.scala new file mode 100644 index 00000000..d2222379 --- /dev/null +++ b/modules/core/shared/src/test/scala/TraceValueTest.scala @@ -0,0 +1,12 @@ +// Copyright (c) 2019-2020 by Rob Norris and Contributors +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package natchez + +import cats.Id + +object TraceValueTest { + // should compile + def traceValueLong() = Trace.Implicits.noop[Id].put(fields = ("foo", 1L)) +} From 00f6a0623b7242f38549438263b09ab50039efe6 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 17 Jul 2022 18:12:42 +0000 Subject: [PATCH 137/178] Update fs2-io to 3.2.10 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index f1e8a91e..04025e71 100644 --- a/build.sbt +++ b/build.sbt @@ -326,7 +326,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", - "co.fs2" %%% "fs2-io" % "3.2.9", + "co.fs2" %%% "fs2-io" % "3.2.10", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" ) From abe8c1bfd39a6850e0592a0d74ae3e3dabb52d75 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 17 Jul 2022 18:13:03 +0000 Subject: [PATCH 138/178] Update telemetry-core, ... to 0.15.0 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index f1e8a91e..fbad498e 100644 --- a/build.sbt +++ b/build.sbt @@ -274,8 +274,8 @@ lazy val newrelic = project "io.circe" %% "circe-core" % "0.14.1", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", - "com.newrelic.telemetry" % "telemetry-core" % "0.12.0", - "com.newrelic.telemetry" % "telemetry-http-okhttp" % "0.12.0" + "com.newrelic.telemetry" % "telemetry-core" % "0.15.0", + "com.newrelic.telemetry" % "telemetry-http-okhttp" % "0.15.0" ) ) From f8db93456ba8661bb3a9d4b54dea42c06baee1ff Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 17 Jul 2022 18:13:19 +0000 Subject: [PATCH 139/178] Update ciris to 2.3.3 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index f1e8a91e..05850e65 100644 --- a/build.sbt +++ b/build.sbt @@ -365,7 +365,7 @@ lazy val examples = project "org.typelevel" %% "log4cats-slf4j" % "2.1.1", "org.slf4j" % "slf4j-simple" % "1.7.36", "eu.timepit" %% "refined" % "0.9.28", - "is.cir" %% "ciris" % "2.3.2" + "is.cir" %% "ciris" % "2.3.3" ) ) From d0113d267144f069966ba719f7ce868604dcfbe7 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 17 Jul 2022 18:13:37 +0000 Subject: [PATCH 140/178] Update cats-effect, cats-effect-kernel to 3.3.14 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index f1e8a91e..01eb19a7 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ val scala30Version = "3.1.2" val collectionCompatVersion = "2.6.0" val catsVersion = "2.7.0" -val catsEffectVersion = "3.3.12" +val catsEffectVersion = "3.3.14" // We do `evictionCheck` in CI and don't sweat the Java deps for now. inThisBuild(Seq( From 59954da0e1a5ca703027195a1286a70bb153f901 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 17 Jul 2022 18:18:24 +0000 Subject: [PATCH 141/178] Applied Scalafix rule(s) github:typelevel/cats/Cats_v2_2_0?sha=v2.2.0 See https://github.com/typelevel/cats/blob/v2.2.0/scalafix/README.md#migration-to-cats-v220 for details --- modules/lightstep/src/main/scala/Lightstep.scala | 2 +- modules/lightstep/src/main/scala/LightstepEntryPoint.scala | 2 +- modules/mock/src/main/scala/MockSpan.scala | 2 +- modules/newrelic/src/main/scala/natchez/newrelic/NewRelic.scala | 2 +- .../newrelic/src/main/scala/natchez/newrelic/NewrelicSpan.scala | 2 +- .../src/main/scala/natchez/opentracing/GlobalTracer.scala | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/lightstep/src/main/scala/Lightstep.scala b/modules/lightstep/src/main/scala/Lightstep.scala index 00b02d61..fa853cc3 100644 --- a/modules/lightstep/src/main/scala/Lightstep.scala +++ b/modules/lightstep/src/main/scala/Lightstep.scala @@ -6,7 +6,7 @@ package natchez package lightstep import cats.effect.{ Resource, Sync } -import cats.implicits._ +import cats.syntax.all._ import com.lightstep.tracer.shared.Options.OptionsBuilder import io.opentracing.Tracer import natchez.opentracing.GlobalTracer diff --git a/modules/lightstep/src/main/scala/LightstepEntryPoint.scala b/modules/lightstep/src/main/scala/LightstepEntryPoint.scala index ca5b353d..aa86b3be 100644 --- a/modules/lightstep/src/main/scala/LightstepEntryPoint.scala +++ b/modules/lightstep/src/main/scala/LightstepEntryPoint.scala @@ -6,7 +6,7 @@ package natchez package lightstep import cats.effect.{ Resource, Sync } -import cats.implicits._ +import cats.syntax.all._ import io.opentracing.Tracer import io.opentracing.propagation.{ Format, TextMapAdapter } diff --git a/modules/mock/src/main/scala/MockSpan.scala b/modules/mock/src/main/scala/MockSpan.scala index 0acbecb1..cdfe79c9 100644 --- a/modules/mock/src/main/scala/MockSpan.scala +++ b/modules/mock/src/main/scala/MockSpan.scala @@ -8,7 +8,7 @@ package mock import scala.jdk.CollectionConverters._ import cats.effect.{ Resource, Sync } -import cats.implicits._ +import cats.syntax.all._ import io.{ opentracing => ot } import io.opentracing.propagation.{ Format, TextMapAdapter } import natchez.TraceValue.{ BooleanValue, NumberValue, StringValue } diff --git a/modules/newrelic/src/main/scala/natchez/newrelic/NewRelic.scala b/modules/newrelic/src/main/scala/natchez/newrelic/NewRelic.scala index 7969d472..7ff6e2d6 100644 --- a/modules/newrelic/src/main/scala/natchez/newrelic/NewRelic.scala +++ b/modules/newrelic/src/main/scala/natchez/newrelic/NewRelic.scala @@ -5,7 +5,7 @@ package natchez.newrelic import cats.effect._ -import cats.implicits._ +import cats.syntax.all._ import com.newrelic.telemetry.spans.SpanBatchSender import natchez.{EntryPoint, Kernel, Span} diff --git a/modules/newrelic/src/main/scala/natchez/newrelic/NewrelicSpan.scala b/modules/newrelic/src/main/scala/natchez/newrelic/NewrelicSpan.scala index 78ae3220..4510064d 100644 --- a/modules/newrelic/src/main/scala/natchez/newrelic/NewrelicSpan.scala +++ b/modules/newrelic/src/main/scala/natchez/newrelic/NewrelicSpan.scala @@ -9,7 +9,7 @@ import java.util.UUID import cats.effect.Ref import cats.effect.{Resource, Sync} -import cats.implicits._ +import cats.syntax.all._ import com.newrelic.telemetry.Attributes import com.newrelic.telemetry.spans.{Span, SpanBatch, SpanBatchSender} import natchez.TraceValue.{BooleanValue, NumberValue, StringValue} diff --git a/modules/opentracing/src/main/scala/natchez/opentracing/GlobalTracer.scala b/modules/opentracing/src/main/scala/natchez/opentracing/GlobalTracer.scala index e9ba2fe1..0b89e58f 100644 --- a/modules/opentracing/src/main/scala/natchez/opentracing/GlobalTracer.scala +++ b/modules/opentracing/src/main/scala/natchez/opentracing/GlobalTracer.scala @@ -6,7 +6,7 @@ package natchez package opentracing import cats.effect.Sync -import cats.implicits._ +import cats.syntax.all._ import io.opentracing.util.{ GlobalTracer => GT } import io.{opentracing => ot} From 69240f063fce819173e742ae9fc976fcff95da20 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 17 Jul 2022 18:18:24 +0000 Subject: [PATCH 142/178] Update log4cats-core, log4cats-slf4j to 2.4.0 --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index f1e8a91e..53690e54 100644 --- a/build.sbt +++ b/build.sbt @@ -250,7 +250,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", - "org.typelevel" %%% "log4cats-core" % "2.1.1", + "org.typelevel" %%% "log4cats-core" % "2.4.0", "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, ) ) @@ -362,7 +362,7 @@ lazy val examples = project description := "Example programs for Natchez.", scalacOptions -= "-Xfatal-warnings", libraryDependencies ++= Seq( - "org.typelevel" %% "log4cats-slf4j" % "2.1.1", + "org.typelevel" %% "log4cats-slf4j" % "2.4.0", "org.slf4j" % "slf4j-simple" % "1.7.36", "eu.timepit" %% "refined" % "0.9.28", "is.cir" %% "ciris" % "2.3.2" @@ -416,7 +416,7 @@ lazy val docs = project libraryDependencies ++= Seq( "org.http4s" %% "http4s-dsl" % "0.23.7", "org.http4s" %% "http4s-client" % "0.23.7", - "org.typelevel" %% "log4cats-slf4j" % "2.1.1", + "org.typelevel" %% "log4cats-slf4j" % "2.4.0", "org.slf4j" % "slf4j-simple" % "1.7.36", ), excludeDependencies += "org.scala-lang.modules" % "scala-collection-compat_3", // pray this does more good than harm From ad1c65891330df367264b0c5179cde4e2cb5285e Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 19 Jul 2022 18:46:58 +0000 Subject: [PATCH 143/178] Revert commit(s) dc0da7a --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 3eb8b7ae..f1e8a91e 100644 --- a/build.sbt +++ b/build.sbt @@ -249,7 +249,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.2", + "io.circe" %%% "circe-core" % "0.14.1", "org.typelevel" %%% "log4cats-core" % "2.1.1", "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, ) @@ -271,7 +271,7 @@ lazy val newrelic = project name := "newrelic", description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.14.2", + "io.circe" %% "circe-core" % "0.14.1", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.12.0", @@ -325,7 +325,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) name := "natchez-xray", description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.2", + "io.circe" %%% "circe-core" % "0.14.1", "co.fs2" %%% "fs2-io" % "3.2.9", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" From 90a5c49b2c4324506e3425d99b5dd6f57cd7eca1 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 19 Jul 2022 18:46:58 +0000 Subject: [PATCH 144/178] Update circe-core to 0.14.2 --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 04025e71..17618265 100644 --- a/build.sbt +++ b/build.sbt @@ -249,7 +249,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", + "io.circe" %%% "circe-core" % "0.14.2", "org.typelevel" %%% "log4cats-core" % "2.1.1", "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, ) @@ -271,7 +271,7 @@ lazy val newrelic = project name := "newrelic", description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.14.1", + "io.circe" %% "circe-core" % "0.14.2", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.12.0", @@ -325,7 +325,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) name := "natchez-xray", description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", + "io.circe" %%% "circe-core" % "0.14.2", "co.fs2" %%% "fs2-io" % "3.2.10", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" From bfe02b0342a3c9592532693242b2bac25de79e22 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 23 Jul 2022 17:37:39 +0000 Subject: [PATCH 145/178] Update netty-tcnative-boringssl-static to 2.0.54.Final --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 04025e71..47a457db 100644 --- a/build.sbt +++ b/build.sbt @@ -192,7 +192,7 @@ lazy val lightstepGrpc = project libraryDependencies ++= Seq( "com.lightstep.tracer" % "tracer-grpc" % "0.30.3", "io.grpc" % "grpc-netty" % "1.42.2", - "io.netty" % "netty-tcnative-boringssl-static" % "2.0.46.Final" + "io.netty" % "netty-tcnative-boringssl-static" % "2.0.54.Final" ) ) From c59ad9711650b8e0238bacda1f60c059ef66b128 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 27 Jul 2022 18:41:02 +0000 Subject: [PATCH 146/178] Update fs2-io to 3.2.11 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 04025e71..46fe9a5f 100644 --- a/build.sbt +++ b/build.sbt @@ -326,7 +326,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", - "co.fs2" %%% "fs2-io" % "3.2.10", + "co.fs2" %%% "fs2-io" % "3.2.11", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" ) From c4edbe1f5ef1e40794ea2ad150e08c7e19ee96c4 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 27 Jul 2022 18:41:15 +0000 Subject: [PATCH 147/178] Update mdoc, sbt-mdoc to 2.3.3 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index ad0dbb9a..e1e04198 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -8,4 +8,4 @@ addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.24") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.3") From 6858f804dba73c0a99deaf295ac3531e170c1047 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 29 Jul 2022 21:02:59 +0000 Subject: [PATCH 148/178] Revert commit(s) 90a5c49 --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 17618265..04025e71 100644 --- a/build.sbt +++ b/build.sbt @@ -249,7 +249,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.2", + "io.circe" %%% "circe-core" % "0.14.1", "org.typelevel" %%% "log4cats-core" % "2.1.1", "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, ) @@ -271,7 +271,7 @@ lazy val newrelic = project name := "newrelic", description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.14.2", + "io.circe" %% "circe-core" % "0.14.1", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.12.0", @@ -325,7 +325,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) name := "natchez-xray", description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.2", + "io.circe" %%% "circe-core" % "0.14.1", "co.fs2" %%% "fs2-io" % "3.2.10", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" From a7ec812f4b37bc99f144c407e12c95da8006d2a2 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 29 Jul 2022 21:02:59 +0000 Subject: [PATCH 149/178] Update circe-core to 0.14.2 --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 46fe9a5f..c872a767 100644 --- a/build.sbt +++ b/build.sbt @@ -249,7 +249,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", + "io.circe" %%% "circe-core" % "0.14.2", "org.typelevel" %%% "log4cats-core" % "2.1.1", "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, ) @@ -271,7 +271,7 @@ lazy val newrelic = project name := "newrelic", description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.14.1", + "io.circe" %% "circe-core" % "0.14.2", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.12.0", @@ -325,7 +325,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) name := "natchez-xray", description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", + "io.circe" %%% "circe-core" % "0.14.2", "co.fs2" %%% "fs2-io" % "3.2.11", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" From c5222721d4f97bc1f22f9fcec5e75537b6fb157b Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 29 Jul 2022 21:03:06 +0000 Subject: [PATCH 150/178] Update scala-collection-compat to 2.8.1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 46fe9a5f..80604d7c 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ val scala212Version = "2.12.15" val scala213Version = "2.13.8" val scala30Version = "3.1.2" -val collectionCompatVersion = "2.6.0" +val collectionCompatVersion = "2.8.1" val catsVersion = "2.7.0" val catsEffectVersion = "3.3.12" From 7ddd1ef76a499211bfd4efcb94ed07444ba22b4f Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 11 Aug 2022 04:08:31 +0000 Subject: [PATCH 151/178] Update fs2-io to 3.2.12 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 46fe9a5f..874a98a4 100644 --- a/build.sbt +++ b/build.sbt @@ -326,7 +326,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", - "co.fs2" %%% "fs2-io" % "3.2.11", + "co.fs2" %%% "fs2-io" % "3.2.12", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" ) From 04a4b77ef281e2c5200d22ac08b37cd49823577b Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 11 Aug 2022 04:08:49 +0000 Subject: [PATCH 152/178] Update libhoney-java to 1.5.2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 46fe9a5f..8ff8b41e 100644 --- a/build.sbt +++ b/build.sbt @@ -150,7 +150,7 @@ lazy val honeycomb = project description := "Honeycomb support for Natchez.", libraryDependencies ++= Seq( "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, - "io.honeycomb.libhoney" % "libhoney-java" % "1.4.1" + "io.honeycomb.libhoney" % "libhoney-java" % "1.5.2" ) ) From 236a57fb6af626ecfa18730ce69dad487f495561 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 12 Aug 2022 19:42:15 +0000 Subject: [PATCH 153/178] Revert commit(s) a7ec812 --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index c872a767..46fe9a5f 100644 --- a/build.sbt +++ b/build.sbt @@ -249,7 +249,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.2", + "io.circe" %%% "circe-core" % "0.14.1", "org.typelevel" %%% "log4cats-core" % "2.1.1", "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, ) @@ -271,7 +271,7 @@ lazy val newrelic = project name := "newrelic", description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.14.2", + "io.circe" %% "circe-core" % "0.14.1", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.12.0", @@ -325,7 +325,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) name := "natchez-xray", description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.2", + "io.circe" %%% "circe-core" % "0.14.1", "co.fs2" %%% "fs2-io" % "3.2.11", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" From 00d452adbb08b4e93730472780a634296ee9f243 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 12 Aug 2022 19:42:15 +0000 Subject: [PATCH 154/178] Update circe-core to 0.14.2 --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 874a98a4..6ff85046 100644 --- a/build.sbt +++ b/build.sbt @@ -249,7 +249,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", + "io.circe" %%% "circe-core" % "0.14.2", "org.typelevel" %%% "log4cats-core" % "2.1.1", "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, ) @@ -271,7 +271,7 @@ lazy val newrelic = project name := "newrelic", description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.14.1", + "io.circe" %% "circe-core" % "0.14.2", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.12.0", @@ -325,7 +325,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) name := "natchez-xray", description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", + "io.circe" %%% "circe-core" % "0.14.2", "co.fs2" %%% "fs2-io" % "3.2.12", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" From fe0c21b12be2e5f65eff1f68bf37ceb9c9732a2f Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 22 Aug 2022 16:53:30 +0000 Subject: [PATCH 155/178] Update slf4j-simple to 2.0.0 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 874a98a4..4bca5e64 100644 --- a/build.sbt +++ b/build.sbt @@ -363,7 +363,7 @@ lazy val examples = project scalacOptions -= "-Xfatal-warnings", libraryDependencies ++= Seq( "org.typelevel" %% "log4cats-slf4j" % "2.1.1", - "org.slf4j" % "slf4j-simple" % "1.7.36", + "org.slf4j" % "slf4j-simple" % "2.0.0", "eu.timepit" %% "refined" % "0.9.28", "is.cir" %% "ciris" % "2.3.2" ) @@ -417,7 +417,7 @@ lazy val docs = project "org.http4s" %% "http4s-dsl" % "0.23.7", "org.http4s" %% "http4s-client" % "0.23.7", "org.typelevel" %% "log4cats-slf4j" % "2.1.1", - "org.slf4j" % "slf4j-simple" % "1.7.36", + "org.slf4j" % "slf4j-simple" % "2.0.0", ), excludeDependencies += "org.scala-lang.modules" % "scala-collection-compat_3", // pray this does more good than harm ) From 2dd6e54825d8736b23e93ac4bc8f410a6ca708c3 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 24 Aug 2022 19:53:25 +0000 Subject: [PATCH 156/178] Update grpc-netty to 1.49.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 874a98a4..77126548 100644 --- a/build.sbt +++ b/build.sbt @@ -191,7 +191,7 @@ lazy val lightstepGrpc = project description := "Lightstep gRPC bindings for Natchez.", libraryDependencies ++= Seq( "com.lightstep.tracer" % "tracer-grpc" % "0.30.3", - "io.grpc" % "grpc-netty" % "1.42.2", + "io.grpc" % "grpc-netty" % "1.49.0", "io.netty" % "netty-tcnative-boringssl-static" % "2.0.46.Final" ) ) From bff998e8808c125ee8e0edb9c6898d49d40fbd65 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 24 Aug 2022 19:53:34 +0000 Subject: [PATCH 157/178] Update http4s-client, http4s-dsl to 0.23.15 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 874a98a4..34aa56e3 100644 --- a/build.sbt +++ b/build.sbt @@ -414,8 +414,8 @@ lazy val docs = project makeSite := makeSite.dependsOn(mdoc.toTask("")).value, mdocExtraArguments := Seq("--no-link-hygiene"), // paradox handles this libraryDependencies ++= Seq( - "org.http4s" %% "http4s-dsl" % "0.23.7", - "org.http4s" %% "http4s-client" % "0.23.7", + "org.http4s" %% "http4s-dsl" % "0.23.15", + "org.http4s" %% "http4s-client" % "0.23.15", "org.typelevel" %% "log4cats-slf4j" % "2.1.1", "org.slf4j" % "slf4j-simple" % "1.7.36", ), From e4dd6f71cbf53d16979990ece9cbfd63d8fbc0cc Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 3 Sep 2022 17:13:54 +0000 Subject: [PATCH 158/178] Update dd-trace-api, dd-trace-ot to 0.108.1 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 874a98a4..b3297378 100644 --- a/build.sbt +++ b/build.sbt @@ -235,8 +235,8 @@ lazy val datadog = project description := "Datadog bindings for Natchez.", libraryDependencies ++= Seq( "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, - "com.datadoghq" % "dd-trace-ot" % "0.91.0", - "com.datadoghq" % "dd-trace-api" % "0.91.0" + "com.datadoghq" % "dd-trace-ot" % "0.108.1", + "com.datadoghq" % "dd-trace-api" % "0.108.1" ) ) From 83eefb40a118ab5b49af1489a8ad2e75cff89ea4 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 11 Sep 2022 18:28:07 +0000 Subject: [PATCH 159/178] Update fs2-io to 3.2.14 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 874a98a4..c4efc1f0 100644 --- a/build.sbt +++ b/build.sbt @@ -326,7 +326,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( "io.circe" %%% "circe-core" % "0.14.1", - "co.fs2" %%% "fs2-io" % "3.2.12", + "co.fs2" %%% "fs2-io" % "3.2.14", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" ) From 343da4372d27cc83a8cf8063ab497f9816c56c79 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 13 Sep 2022 18:09:03 +0000 Subject: [PATCH 160/178] Revert commit(s) 00d452a --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 6ff85046..874a98a4 100644 --- a/build.sbt +++ b/build.sbt @@ -249,7 +249,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.2", + "io.circe" %%% "circe-core" % "0.14.1", "org.typelevel" %%% "log4cats-core" % "2.1.1", "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, ) @@ -271,7 +271,7 @@ lazy val newrelic = project name := "newrelic", description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.14.2", + "io.circe" %% "circe-core" % "0.14.1", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.12.0", @@ -325,7 +325,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) name := "natchez-xray", description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.2", + "io.circe" %%% "circe-core" % "0.14.1", "co.fs2" %%% "fs2-io" % "3.2.12", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" From 4729253faa9d48e18acd4d94e44b161716fb6bd3 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 13 Sep 2022 18:09:04 +0000 Subject: [PATCH 161/178] Update circe-core to 0.14.2 --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index c4efc1f0..bb43b297 100644 --- a/build.sbt +++ b/build.sbt @@ -249,7 +249,7 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", + "io.circe" %%% "circe-core" % "0.14.2", "org.typelevel" %%% "log4cats-core" % "2.1.1", "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, ) @@ -271,7 +271,7 @@ lazy val newrelic = project name := "newrelic", description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.14.1", + "io.circe" %% "circe-core" % "0.14.2", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.12.0", @@ -325,7 +325,7 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) name := "natchez-xray", description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", + "io.circe" %%% "circe-core" % "0.14.2", "co.fs2" %%% "fs2-io" % "3.2.14", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.31" From cd5903504016ea4b6acf3330e98e79598a036f06 Mon Sep 17 00:00:00 2001 From: Michael Pilquist Date: Sat, 1 Oct 2022 16:16:55 -0400 Subject: [PATCH 162/178] Update Scala.js and SBT --- project/build.properties | 2 +- project/plugins.sbt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/project/build.properties b/project/build.properties index baf5ff3e..22af2628 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.7 +sbt.version=1.7.1 diff --git a/project/plugins.sbt b/project/plugins.sbt index e1e04198..7bd1e53b 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,11 +1,11 @@ -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.5") addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.0") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.3") From d52d3131750f9f234a8a3ae302dd5a1c682a93cc Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 1 Oct 2022 20:38:13 +0000 Subject: [PATCH 163/178] Migrate to sbt-typelevel --- .github/workflows/build.yml | 20 --- .github/workflows/ci.yml | 266 ++++++++++++++++++++++++++++++++++ .github/workflows/clean.yml | 59 ++++++++ .github/workflows/release.yml | 18 --- .scalafmt.conf | 3 + build.sbt | 152 ++++++++----------- project/build.properties | 2 +- project/plugins.sbt | 20 ++- 8 files changed, 396 insertions(+), 144 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/clean.yml delete mode 100644 .github/workflows/release.yml create mode 100644 .scalafmt.conf diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 49441624..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Build - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK - uses: olafurpg/setup-scala@v10 - - name: Cache SBT - uses: actions/cache@v2 - with: - path: | - ~/.cache/coursier/v1 - ~/.sbt - key: sbt-${{ hashFiles('**/build.sbt') }} - - name: Run tests - run: sbt headerCheck +clean +test docs/makeSite diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..8e8ace50 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,266 @@ +# This file was automatically generated by sbt-github-actions using the +# githubWorkflowGenerate task. You should add and commit this file to +# your git repository. It goes without saying that you shouldn't edit +# this file by hand! Instead, if you wish to make changes, you should +# change your sbt build configuration to revise the workflow description +# to meet your needs, then regenerate this file. + +name: Continuous Integration + +on: + pull_request: + branches: ['**', '!update/**', '!pr/**'] + push: + branches: ['**', '!update/**', '!pr/**'] + tags: [v*] + +env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + name: Build and Test + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.12.15, 2.13.8, 3.1.2] + java: [temurin@8] + project: [rootJS, rootJVM] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Download Java (temurin@8) + id: download-java-temurin-8 + if: matrix.java == 'temurin@8' + uses: typelevel/download-java@v1 + with: + distribution: temurin + java-version: 8 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v2 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} + + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + + - name: Check that workflows are up to date + run: sbt githubWorkflowCheck + + - name: Check headers and formatting + if: matrix.java == 'temurin@8' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck + + - name: scalaJSLink + if: matrix.project == 'rootJS' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/scalaJSLinkerResult + + - name: Test + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test + + - name: Check binary compatibility + if: matrix.java == 'temurin@8' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' mimaReportBinaryIssues + + - name: Generate API documentation + if: matrix.java == 'temurin@8' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' doc + + - name: Make target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + run: mkdir -p modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target .js/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/mtl/jvm/target modules/lightstep/target project/target + + - name: Compress target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + run: tar cf targets.tar modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target .js/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/mtl/jvm/target modules/lightstep/target project/target + + - name: Upload target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + uses: actions/upload-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }} + path: targets.tar + + publish: + name: Publish Artifacts + needs: [build] + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.8] + java: [temurin@8] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Download Java (temurin@8) + id: download-java-temurin-8 + if: matrix.java == 'temurin@8' + uses: typelevel/download-java@v1 + with: + distribution: temurin + java-version: 8 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v2 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} + + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + + - name: Download target directories (2.12.15, rootJS) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJS + + - name: Inflate target directories (2.12.15, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.15, rootJVM) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJVM + + - name: Inflate target directories (2.12.15, rootJVM) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.8, rootJS) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJS + + - name: Inflate target directories (2.13.8, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.8, rootJVM) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJVM + + - name: Inflate target directories (2.13.8, rootJVM) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (3.1.2, rootJS) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.2-rootJS + + - name: Inflate target directories (3.1.2, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (3.1.2, rootJVM) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.2-rootJVM + + - name: Inflate target directories (3.1.2, rootJVM) + run: | + tar xf targets.tar + rm targets.tar + + - name: Import signing key + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == '' + run: echo $PGP_SECRET | base64 -di | gpg --import + + - name: Import signing key and strip passphrase + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != '' + run: | + echo "$PGP_SECRET" | base64 -di > /tmp/signing-key.gpg + echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg + (echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1) + + - name: Publish + run: sbt '++${{ matrix.scala }}' tlRelease + + docs: + name: Make site + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.8] + java: [temurin@11] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Download Java (temurin@8) + id: download-java-temurin-8 + if: matrix.java == 'temurin@8' + uses: typelevel/download-java@v1 + with: + distribution: temurin + java-version: 8 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v2 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} + + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + + - run: sbt '++${{ matrix.scala }}' docs/makeSite diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml new file mode 100644 index 00000000..547aaa43 --- /dev/null +++ b/.github/workflows/clean.yml @@ -0,0 +1,59 @@ +# This file was automatically generated by sbt-github-actions using the +# githubWorkflowGenerate task. You should add and commit this file to +# your git repository. It goes without saying that you shouldn't edit +# this file by hand! Instead, if you wish to make changes, you should +# change your sbt build configuration to revise the workflow description +# to meet your needs, then regenerate this file. + +name: Clean + +on: push + +jobs: + delete-artifacts: + name: Delete Artifacts + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Delete artifacts + run: | + # Customize those three lines with your repository and credentials: + REPO=${GITHUB_API_URL}/repos/${{ github.repository }} + + # A shortcut to call GitHub API. + ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; } + + # A temporary file which receives HTTP response headers. + TMPFILE=/tmp/tmp.$$ + + # An associative array, key: artifact name, value: number of artifacts of that name. + declare -A ARTCOUNT + + # Process all artifacts on this repository, loop on returned "pages". + URL=$REPO/actions/artifacts + while [[ -n "$URL" ]]; do + + # Get current page, get response headers in a temporary file. + JSON=$(ghapi --dump-header $TMPFILE "$URL") + + # Get URL of next page. Will be empty if we are at the last page. + URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*.*//') + rm -f $TMPFILE + + # Number of artifacts on this page: + COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') )) + + # Loop on all artifacts on this page. + for ((i=0; $i < $COUNT; i++)); do + + # Get name of artifact and count instances of this name. + name=$(jq <<<$JSON -r ".artifacts[$i].name?") + ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1)) + + id=$(jq <<<$JSON -r ".artifacts[$i].id?") + size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") )) + printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size + ghapi -X DELETE $REPO/actions/artifacts/$id + done + done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index dc59c065..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Release -on: - push: - tags: ["*"] -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: olafurpg/setup-scala@v10 - - uses: olafurpg/setup-gpg@v3 - - name: Publish - run: sbt ci-release - env: - PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} - PGP_SECRET: ${{ secrets.PGP_SECRET }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 00000000..5fbe01d2 --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,3 @@ +version = "3.5.9" +runner.dialect = Scala213Source3 +project.includePaths = [] # disables formatting diff --git a/build.sbt b/build.sbt index 6bc7dfaa..b35fa49b 100644 --- a/build.sbt +++ b/build.sbt @@ -1,3 +1,5 @@ +ThisBuild / tlBaseVersion := "0.1" + val scala212Version = "2.12.15" val scala213Version = "2.13.8" val scala30Version = "3.1.2" @@ -7,107 +9,72 @@ val collectionCompatVersion = "2.8.1" val catsVersion = "2.7.0" val catsEffectVersion = "3.3.14" -// We do `evictionCheck` in CI and don't sweat the Java deps for now. -inThisBuild(Seq( - evictionRules ++= Seq( - "io.netty" % "*" % "always", - "io.grpc" % "*" % "always", - "com.github.jnr" % "*" % "always", - "com.google.guava" % "*" % "always", - "io.opentracing" % "*" % "always", - "io.opentracing.contrib" % "*" % "always", - "com.squareup.okhttp3" % "*" % "always", - "com.squareup.okio" % "*" % "always", - "com.newrelic.telemetry" % "*" % "always", - "org.typelevel" % "*" % "semver-spec", - "org.scala-js" % "*" % "semver-spec", - "org.jctools" % "*" % "always", - "org.jetbrains" % "*" % "always", - "org.jboss.logging" % "*" % "always", - "org.jboss.threads" % "*" % "always", - "org.wildfly.common" % "*" % "always", - "org.jboss.xnio" % "*" % "always", - "com.lihaoyi" % "*" % "always", +// Publishing + +ThisBuild / organization := "org.tpolecat" +ThisBuild / licenses := Seq(("MIT", url("http://opensource.org/licenses/MIT"))) +ThisBuild / developers := List( + Developer("tpolecat", "Rob Norris", "rob_norris@mac.com", url("http://www.tpolecat.org")) +) +ThisBuild / tlSonatypeUseLegacyHost := false + +// start MiMa from here +ThisBuild / tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.1.6").toMap + +ThisBuild / githubWorkflowAddedJobs += + WorkflowJob( + id = "docs", + name = s"Make site", + scalas = List(scala213Version), + steps = List(WorkflowStep.CheckoutFull) ++ + WorkflowStep.SetupJava(githubWorkflowJavaVersions.value.toList) ++ + githubWorkflowGeneratedCacheSteps.value ++ + List(WorkflowStep.Sbt(List("docs/makeSite"))) ) -)) -// Global Settings +// Headers lazy val commonSettings = Seq( - - // Publishing - organization := "org.tpolecat", - licenses ++= Seq(("MIT", url("http://opensource.org/licenses/MIT"))), - homepage := Some(url("https://github.com/tpolecat/natchez")), - developers := List( - Developer("tpolecat", "Rob Norris", "rob_norris@mac.com", url("http://www.tpolecat.org")) - ), - - // Headers headerMappings := headerMappings.value + (HeaderFileType.scala -> HeaderCommentStyle.cppStyleLineComment), headerLicense := Some(HeaderLicense.Custom( """|Copyright (c) 2019-2020 by Rob Norris and Contributors - |This software is licensed under the MIT License (MIT). - |For more information see LICENSE or https://opensource.org/licenses/MIT - |""".stripMargin + |This software is licensed under the MIT License (MIT). + |For more information see LICENSE or https://opensource.org/licenses/MIT + |""".stripMargin ) - ), - - // Testing - libraryDependencies ++= Seq( - "org.scalameta" %%% "munit" % "0.7.29" % Test, - "org.scalameta" %%% "munit-scalacheck" % "0.7.29" % Test, - "org.typelevel" %%% "munit-cats-effect-3" % "1.0.7" % Test, - ), - testFrameworks += new TestFramework("munit.Framework"), - - // Compilation - scalaVersion := scala213Version, - crossScalaVersions := Seq(scala212Version, scala213Version, scala30Version), - Compile / console / scalacOptions --= Seq("-Xfatal-warnings", "-Ywarn-unused:imports"), - Compile / doc / scalacOptions --= Seq("-Xfatal-warnings"), - Compile / doc / scalacOptions ++= Seq( - "-groups", - "-sourcepath", (LocalRootProject / baseDirectory).value.getAbsolutePath, - "-doc-source-url", "https://github.com/tpolecat/natchez/blob/v" + version.value + "€{FILE_PATH}.scala" - ), - libraryDependencies ++= Seq( - compilerPlugin("org.typelevel" %% "kind-projector" % "0.13.2" cross CrossVersion.full), - ).filterNot(_ => scalaVersion.value.startsWith("3.")), - - // dottydoc really doesn't work at all right now - Compile / doc / sources := { - val old = (Compile / doc / sources).value - if (scalaVersion.value.startsWith("3.")) - Seq() - else - old - }, + ) +) +// Testing +ThisBuild / libraryDependencies ++= Seq( + "org.scalameta" %%% "munit" % "0.7.29" % Test, + "org.scalameta" %%% "munit-scalacheck" % "0.7.29" % Test, + "org.typelevel" %%% "munit-cats-effect-3" % "1.0.7" % Test, ) -// root project -commonSettings -publish / skip := true - -lazy val crossProjectSettings = Seq( - Compile / unmanagedSourceDirectories ++= { - val major = if (scalaVersion.value.startsWith("3.")) "-3" else "-2" - List(CrossType.Pure, CrossType.Full).flatMap( - _.sharedSrcDir(baseDirectory.value, "main").toList.map(f => file(f.getPath + major))) - }, - - Test / unmanagedSourceDirectories ++= { - val major = if (scalaVersion.value.startsWith("3.")) "-3" else "-2" - List(CrossType.Pure, CrossType.Full).flatMap( - _.sharedSrcDir(baseDirectory.value, "test").toList.map(f => file(f.getPath + major))) - }, +// Compilation +ThisBuild / scalaVersion := scala213Version +ThisBuild / crossScalaVersions := Seq(scala212Version, scala213Version, scala30Version) + +lazy val root = tlCrossRootProject.aggregate( + core, + jaeger, + honeycomb, + opencensus, + lightstep, lightstepGrpc, lightstepHttp, + opentracing, + datadog, + log, + newrelic, + mtl, + noop, + xray, + examples ) lazy val core = crossProject(JSPlatform, JVMPlatform) .in(file("modules/core")) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) - .settings(crossProjectSettings) .settings( name := "natchez-core", description := "Tagless, non-blocking OpenTracing implementation for Scala.", @@ -193,7 +160,8 @@ lazy val lightstepGrpc = project "com.lightstep.tracer" % "tracer-grpc" % "0.30.3", "io.grpc" % "grpc-netty" % "1.49.0", "io.netty" % "netty-tcnative-boringssl-static" % "2.0.54.Final" - ) + ), + mimaPreviousArtifacts := Set() ) lazy val lightstepHttp = project @@ -206,7 +174,8 @@ lazy val lightstepHttp = project description := "Lightstep HTTP bindings for Natchez.", libraryDependencies ++= Seq( "com.lightstep.tracer" % "tracer-okhttp" % "0.30.3" - ) + ), + mimaPreviousArtifacts := Set() ) lazy val opentracing = project @@ -244,7 +213,6 @@ lazy val log = crossProject(JSPlatform, JVMPlatform) .in(file("modules/log")) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) - .settings(crossProjectSettings) .settings( name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", @@ -320,7 +288,6 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) .dependsOn(core) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) - .settings(crossProjectSettings) .settings( name := "natchez-xray", description := "AWS X-Ray bindings implementation", @@ -354,10 +321,9 @@ lazy val mock = project lazy val examples = project .in(file("modules/examples")) .dependsOn(coreJVM, jaeger, honeycomb, lightstepHttp, datadog, newrelic, logJVM) - .enablePlugins(AutomateHeaderPlugin) + .enablePlugins(AutomateHeaderPlugin, NoPublishPlugin) .settings(commonSettings) .settings( - publish / skip := true, name := "natchez-examples", description := "Example programs for Natchez.", scalacOptions -= "-Xfatal-warnings", @@ -373,8 +339,7 @@ lazy val examples = project // .in(file("modules/log-odin")) // .dependsOn(coreJVM) // .enablePlugins(AutomateHeaderPlugin) -// .settings(commonSettings) -// .settings( +// // .settings( // publish / skip := scalaVersion.value.startsWith("3."), // name := "natchez-log-odin", // description := "Logging bindings for Natchez, using Odin.", @@ -393,7 +358,6 @@ lazy val docs = project .enablePlugins(ParadoxSitePlugin) .enablePlugins(GhpagesPlugin) .enablePlugins(MdocPlugin) - .settings(commonSettings) .settings( scalacOptions := Nil, git.remoteRepo := "git@github.com:tpolecat/natchez.git", diff --git a/project/build.properties b/project/build.properties index baf5ff3e..22af2628 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.7 +sbt.version=1.7.1 diff --git a/project/plugins.sbt b/project/plugins.sbt index e1e04198..fd8581b6 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,11 +1,9 @@ -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.5") -addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2") -addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") -addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.0") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") -addSbtPlugin("ch.epfl.scala" % "sbt-eviction-rules" % "1.0.0-RC1") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.3") +addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.15") +addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2") +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") +addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.7") +addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.3") From bbcaf95641ab2ef5d859a9350a8d196e4ba0b814 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 1 Oct 2022 20:42:33 +0000 Subject: [PATCH 164/178] regenerate workflow --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e8ace50..032f9998 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.12.15, 2.13.8, 3.1.2] + scala: [2.12.15, 2.13.8, 3.1.3] java: [temurin@8] project: [rootJS, rootJVM] runs-on: ${{ matrix.os }} @@ -187,22 +187,22 @@ jobs: tar xf targets.tar rm targets.tar - - name: Download target directories (3.1.2, rootJS) + - name: Download target directories (3.1.3, rootJS) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.2-rootJS + name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.3-rootJS - - name: Inflate target directories (3.1.2, rootJS) + - name: Inflate target directories (3.1.3, rootJS) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (3.1.2, rootJVM) + - name: Download target directories (3.1.3, rootJVM) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.2-rootJVM + name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.3-rootJVM - - name: Inflate target directories (3.1.2, rootJVM) + - name: Inflate target directories (3.1.3, rootJVM) run: | tar xf targets.tar rm targets.tar From f1742a300e95ab8d31abf6ebd4c7db90da21c088 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 1 Oct 2022 20:45:35 +0000 Subject: [PATCH 165/178] add vestigial build job --- .github/workflows/build.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..69e3df5e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,9 @@ +name: Build + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - run: echo dijkstra would not have liked this From d362d33c04686745efa5d291b6a3b388523c9a80 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 1 Oct 2022 20:46:34 +0000 Subject: [PATCH 166/178] regenerate workflow --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 032f9998..3776ef48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.12.15, 2.13.8, 3.1.3] + scala: [2.12.16, 2.13.8, 3.1.3] java: [temurin@8] project: [rootJS, rootJVM] runs-on: ${{ matrix.os }} @@ -147,22 +147,22 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - name: Download target directories (2.12.15, rootJS) + - name: Download target directories (2.12.16, rootJS) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJS + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.16-rootJS - - name: Inflate target directories (2.12.15, rootJS) + - name: Inflate target directories (2.12.16, rootJS) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (2.12.15, rootJVM) + - name: Download target directories (2.12.16, rootJVM) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJVM + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.16-rootJVM - - name: Inflate target directories (2.12.15, rootJVM) + - name: Inflate target directories (2.12.16, rootJVM) run: | tar xf targets.tar rm targets.tar From 832706ea53b2d9911c8e3eb7da82ddad20967e92 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 1 Oct 2022 21:17:21 +0000 Subject: [PATCH 167/178] Cross-build for Native --- .github/workflows/ci.yml | 40 +++++++- .jvmopts | 4 + build.sbt | 95 ++++++++----------- .../log/shared/src/main/scala/LogSpan.scala | 3 +- 4 files changed, 80 insertions(+), 62 deletions(-) create mode 100644 .jvmopts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3776ef48..4fc6ee04 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: os: [ubuntu-latest] scala: [2.12.16, 2.13.8, 3.1.3] java: [temurin@8] - project: [rootJS, rootJVM] + project: [rootJS, rootJVM, rootNative] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -77,6 +77,10 @@ jobs: if: matrix.project == 'rootJS' run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/scalaJSLinkerResult + - name: nativeLink + if: matrix.project == 'rootNative' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/nativeLink + - name: Test run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test @@ -90,11 +94,11 @@ jobs: - name: Make target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') - run: mkdir -p modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target .js/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/mtl/jvm/target modules/lightstep/target project/target + run: mkdir -p modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/noop/native/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/mtl/jvm/target modules/lightstep/target project/target - name: Compress target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') - run: tar cf targets.tar modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target .js/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/mtl/jvm/target modules/lightstep/target project/target + run: tar cf targets.tar modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/noop/native/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/mtl/jvm/target modules/lightstep/target project/target - name: Upload target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') @@ -167,6 +171,16 @@ jobs: tar xf targets.tar rm targets.tar + - name: Download target directories (2.12.16, rootNative) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.16-rootNative + + - name: Inflate target directories (2.12.16, rootNative) + run: | + tar xf targets.tar + rm targets.tar + - name: Download target directories (2.13.8, rootJS) uses: actions/download-artifact@v2 with: @@ -187,6 +201,16 @@ jobs: tar xf targets.tar rm targets.tar + - name: Download target directories (2.13.8, rootNative) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootNative + + - name: Inflate target directories (2.13.8, rootNative) + run: | + tar xf targets.tar + rm targets.tar + - name: Download target directories (3.1.3, rootJS) uses: actions/download-artifact@v2 with: @@ -207,6 +231,16 @@ jobs: tar xf targets.tar rm targets.tar + - name: Download target directories (3.1.3, rootNative) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.3-rootNative + + - name: Inflate target directories (3.1.3, rootNative) + run: | + tar xf targets.tar + rm targets.tar + - name: Import signing key if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == '' run: echo $PGP_SECRET | base64 -di | gpg --import diff --git a/.jvmopts b/.jvmopts new file mode 100644 index 00000000..a04e1fbd --- /dev/null +++ b/.jvmopts @@ -0,0 +1,4 @@ + +-Xms1G +-Xmx4G +-XX:+UseG1GC diff --git a/build.sbt b/build.sbt index ac1f0166..ce26e4ed 100644 --- a/build.sbt +++ b/build.sbt @@ -41,14 +41,17 @@ lazy val commonSettings = Seq( |For more information see LICENSE or https://opensource.org/licenses/MIT |""".stripMargin ) + ), + // Testing + libraryDependencies ++= Seq( + "org.scalameta" %%% "munit" % "1.0.0-M6" % Test, + "org.scalameta" %%% "munit-scalacheck" % "1.0.0-M6" % Test, + "org.typelevel" %%% "munit-cats-effect" % "2.0.0-M3" % Test, ) ) -// Testing -ThisBuild / libraryDependencies ++= Seq( - "org.scalameta" %%% "munit" % "0.7.29" % Test, - "org.scalameta" %%% "munit-scalacheck" % "0.7.29" % Test, - "org.typelevel" %%% "munit-cats-effect-3" % "1.0.7" % Test, +lazy val commonNativeSettings = Seq( + tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.1.6").toMap ) // Compilation @@ -71,7 +74,7 @@ lazy val root = tlCrossRootProject.aggregate( examples ) -lazy val core = crossProject(JSPlatform, JVMPlatform) +lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform) .in(file("modules/core")) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) @@ -84,18 +87,11 @@ lazy val core = crossProject(JSPlatform, JVMPlatform) "org.typelevel" %%% "cats-effect" % catsEffectVersion, ) ) - -lazy val coreJVM = core.jvm -lazy val coreJS = core.js - .settings( - Test / scalaJSStage := FastOptStage, - jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(), - scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), - ) + .nativeSettings(commonNativeSettings) lazy val jaeger = project .in(file("modules/jaeger")) - .dependsOn(coreJVM, opentracing) + .dependsOn(core.jvm, opentracing) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( @@ -109,7 +105,7 @@ lazy val jaeger = project lazy val honeycomb = project .in(file("modules/honeycomb")) - .dependsOn(coreJVM) + .dependsOn(core.jvm) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( @@ -123,7 +119,7 @@ lazy val honeycomb = project lazy val opencensus = project .in(file("modules/opencensus")) - .dependsOn(coreJVM) + .dependsOn(core.jvm) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( @@ -136,7 +132,7 @@ lazy val opencensus = project lazy val lightstep = project .in(file("modules/lightstep")) - .dependsOn(coreJVM, opentracing) + .dependsOn(core.jvm, opentracing) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( @@ -180,7 +176,7 @@ lazy val lightstepHttp = project lazy val opentracing = project .in(file("modules/opentracing")) - .dependsOn(coreJVM) + .dependsOn(core.jvm) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( @@ -196,7 +192,7 @@ lazy val opentracing = project lazy val datadog = project .in(file("modules/datadog")) - .dependsOn(coreJVM, opentracing) + .dependsOn(core.jvm, opentracing) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( @@ -209,37 +205,32 @@ lazy val datadog = project ) ) -lazy val log = crossProject(JSPlatform, JVMPlatform) +lazy val log = crossProject(JSPlatform, JVMPlatform, NativePlatform) .in(file("modules/log")) + .dependsOn(core) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( name := "natchez-log", description := "Logging bindings for Natchez, using log4cats.", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", - "org.typelevel" %%% "log4cats-core" % "2.4.0", - "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" % Test, + "io.circe" %%% "circe-core" % "0.14.3", + "org.typelevel" %%% "log4cats-core" % "2.5.0", + "io.github.cquiroz" %%% "scala-java-time" % "2.4.0" % Test, ) ) -lazy val logJVM = log.jvm.dependsOn(coreJVM) -lazy val logJS = log.js.dependsOn(coreJS) - .settings( - Test / scalaJSStage := FastOptStage, - jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(), - scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), - ) + .nativeSettings(commonNativeSettings) lazy val newrelic = project .in(file("modules/newrelic")) - .dependsOn(coreJVM) + .dependsOn(core.jvm) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( name := "newrelic", description := "Newrelic bindings for Natchez.", libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % "0.14.1", + "io.circe" %% "circe-core" % "0.14.3", "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "com.newrelic.telemetry" % "telemetry" % "0.10.0", "com.newrelic.telemetry" % "telemetry-core" % "0.15.0", @@ -247,8 +238,9 @@ lazy val newrelic = project ) ) -lazy val mtl = crossProject(JSPlatform, JVMPlatform) +lazy val mtl = crossProject(JSPlatform, JVMPlatform, NativePlatform) .in(file("modules/mtl")) + .dependsOn(core) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( @@ -258,16 +250,9 @@ lazy val mtl = crossProject(JSPlatform, JVMPlatform) "org.typelevel" %%% "cats-mtl" % "1.3.0", ) ) + .nativeSettings(commonNativeSettings) -lazy val mtlJVM = mtl.jvm.dependsOn(coreJVM) -lazy val mtlJS = mtl.js.dependsOn(coreJS) - .settings( - Test / scalaJSStage := FastOptStage, - jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(), - scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), - ) - -lazy val noop = crossProject(JSPlatform, JVMPlatform) +lazy val noop = crossProject(JSPlatform, JVMPlatform, NativePlatform) .in(file("modules/noop")) .dependsOn(core) .enablePlugins(AutomateHeaderPlugin) @@ -277,11 +262,7 @@ lazy val noop = crossProject(JSPlatform, JVMPlatform) description := "No-Op Open Tracing implementation", libraryDependencies ++= Seq() ) - .jsSettings( - Test / scalaJSStage := FastOptStage, - jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(), - scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), - ) + .nativeSettings(commonNativeSettings) lazy val xray = crossProject(JSPlatform, JVMPlatform) .in(file("modules/xray")) @@ -292,21 +273,19 @@ lazy val xray = crossProject(JSPlatform, JVMPlatform) name := "natchez-xray", description := "AWS X-Ray bindings implementation", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % "0.14.1", + "io.circe" %%% "circe-core" % "0.14.3", "co.fs2" %%% "fs2-io" % "3.2.14", "com.comcast" %%% "ip4s-core" % "3.1.3", "org.scodec" %%% "scodec-bits" % "1.1.34" ) ) .jsSettings( - Test / scalaJSStage := FastOptStage, - jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(), scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)), ) lazy val mock = project .in(file("modules/mock")) - .dependsOn(coreJVM) + .dependsOn(core.jvm) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( @@ -320,7 +299,7 @@ lazy val mock = project lazy val examples = project .in(file("modules/examples")) - .dependsOn(coreJVM, jaeger, honeycomb, lightstepHttp, datadog, newrelic, logJVM) + .dependsOn(core.jvm, jaeger, honeycomb, lightstepHttp, datadog, newrelic, log.jvm) .enablePlugins(AutomateHeaderPlugin, NoPublishPlugin) .settings(commonSettings) .settings( @@ -328,7 +307,7 @@ lazy val examples = project description := "Example programs for Natchez.", scalacOptions -= "-Xfatal-warnings", libraryDependencies ++= Seq( - "org.typelevel" %% "log4cats-slf4j" % "2.4.0", + "org.typelevel" %% "log4cats-slf4j" % "2.5.0", "org.slf4j" % "slf4j-simple" % "2.0.0", "eu.timepit" %% "refined" % "0.9.28", "is.cir" %% "ciris" % "2.3.3" @@ -337,7 +316,7 @@ lazy val examples = project // lazy val logOdin = project // .in(file("modules/log-odin")) -// .dependsOn(coreJVM) +// .dependsOn(core.jvm) // .enablePlugins(AutomateHeaderPlugin) // // .settings( // publish / skip := scalaVersion.value.startsWith("3."), @@ -352,7 +331,7 @@ lazy val examples = project lazy val docs = project .in(file("modules/docs")) - .dependsOn(mtlJVM, honeycomb, datadog, jaeger, logJVM) + .dependsOn(mtl.jvm, honeycomb, datadog, jaeger, log.jvm) .enablePlugins(AutomateHeaderPlugin) .enablePlugins(ParadoxPlugin) .enablePlugins(ParadoxSitePlugin) @@ -366,10 +345,10 @@ lazy val docs = project paradoxTheme := Some(builtinParadoxTheme("generic")), version := version.value.takeWhile(_ != '+'), // strip off the +3-f22dca22+20191110-1520-SNAPSHOT business paradoxProperties ++= Map( - "scala-versions" -> (coreJVM / crossScalaVersions).value.map(CrossVersion.partialVersion).flatten.distinct.map { case (a, b) => s"$a.$b"} .mkString("/"), + "scala-versions" -> (core.jvm / crossScalaVersions).value.map(CrossVersion.partialVersion).flatten.distinct.map { case (a, b) => s"$a.$b"} .mkString("/"), "org" -> organization.value, "scala.binary.version" -> s"2.${CrossVersion.partialVersion(scalaVersion.value).get._2}", - "core-dep" -> s"${(coreJVM / name).value}_2.${CrossVersion.partialVersion(scalaVersion.value).get._2}", + "core-dep" -> s"${(core.jvm / name).value}_2.${CrossVersion.partialVersion(scalaVersion.value).get._2}", "version" -> version.value, "scaladoc.natchez.base_url" -> s"https://static.javadoc.io/org.tpolecat/natchez-core_2.13/${version.value}", ), diff --git a/modules/log/shared/src/main/scala/LogSpan.scala b/modules/log/shared/src/main/scala/LogSpan.scala index f35211d8..7e9bcc6a 100644 --- a/modules/log/shared/src/main/scala/LogSpan.scala +++ b/modules/log/shared/src/main/scala/LogSpan.scala @@ -6,6 +6,7 @@ package natchez.log import cats.effect.Ref import cats.effect._ +import cats.effect.std.UUIDGen import cats.effect.Resource.ExitCase import cats.effect.Resource.ExitCase._ import cats.syntax.all._ @@ -123,7 +124,7 @@ private[log] object LogSpan { } private def uuid[F[_]: Sync]: F[UUID] = - Sync[F].delay(UUID.randomUUID) + UUIDGen.randomUUID private def now[F[_]: Sync]: F[Instant] = Sync[F].delay(Instant.now) From 6c6c784213a189c53f90c6be7644698cd3e2f47b Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 1 Oct 2022 21:21:37 +0000 Subject: [PATCH 168/178] Publish snapshots --- .github/workflows/ci.yml | 8 ++++---- build.sbt | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fc6ee04..4a3c0ddf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,15 +93,15 @@ jobs: run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' doc - name: Make target directories - if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/0.1') run: mkdir -p modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/noop/native/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/mtl/jvm/target modules/lightstep/target project/target - name: Compress target directories - if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/0.1') run: tar cf targets.tar modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/noop/native/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/mtl/jvm/target modules/lightstep/target project/target - name: Upload target directories - if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/0.1') uses: actions/upload-artifact@v2 with: name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }} @@ -110,7 +110,7 @@ jobs: publish: name: Publish Artifacts needs: [build] - if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/0.1') strategy: matrix: os: [ubuntu-latest] diff --git a/build.sbt b/build.sbt index 002871ba..1e3c8763 100644 --- a/build.sbt +++ b/build.sbt @@ -18,6 +18,8 @@ ThisBuild / developers := List( ) ThisBuild / tlSonatypeUseLegacyHost := false +ThisBuild / tlCiReleaseBranches += "series/0.1" + // start MiMa from here ThisBuild / tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.1.6").toMap From 4609b808c328f6e50385207d5e3b6b629a3c69a6 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 1 Oct 2022 21:24:21 +0000 Subject: [PATCH 169/178] fix native MiMa --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index d3aedf6d..c7b66179 100644 --- a/build.sbt +++ b/build.sbt @@ -53,7 +53,7 @@ lazy val commonSettings = Seq( ) lazy val commonNativeSettings = Seq( - tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.1.6").toMap + tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.1.7").toMap ) // Compilation From 3662f1bcb35e3ac6b41bfc9a18d820b71dd4a242 Mon Sep 17 00:00:00 2001 From: Michael Pilquist Date: Sat, 1 Oct 2022 18:16:45 -0400 Subject: [PATCH 170/178] Add float and double support --- modules/core/shared/src/main/scala/TraceValue.scala | 6 ++++-- modules/core/shared/src/test/scala/TraceValueTest.scala | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/core/shared/src/main/scala/TraceValue.scala b/modules/core/shared/src/main/scala/TraceValue.scala index ff392ae4..b905e281 100644 --- a/modules/core/shared/src/main/scala/TraceValue.scala +++ b/modules/core/shared/src/main/scala/TraceValue.scala @@ -13,10 +13,12 @@ object TraceValue { case class StringValue(value: String) extends TraceValue case class BooleanValue(value: Boolean) extends TraceValue case class NumberValue(value: Number) extends TraceValue - + implicit def stringToTraceValue(value: String): TraceValue = StringValue(value) implicit def boolToTraceValue(value: Boolean): TraceValue = BooleanValue(value) implicit def intToTraceValue(value: Int): TraceValue = NumberValue(value) implicit def longToTraceValue(value: Long): TraceValue = NumberValue(value) + implicit def floatToTraceValue(value: Float): TraceValue = NumberValue(value) + implicit def doubleToTraceValue(value: Double): TraceValue = NumberValue(value) -} \ No newline at end of file +} diff --git a/modules/core/shared/src/test/scala/TraceValueTest.scala b/modules/core/shared/src/test/scala/TraceValueTest.scala index d2222379..2daeaebf 100644 --- a/modules/core/shared/src/test/scala/TraceValueTest.scala +++ b/modules/core/shared/src/test/scala/TraceValueTest.scala @@ -8,5 +8,8 @@ import cats.Id object TraceValueTest { // should compile + def traceValueInt() = Trace.Implicits.noop[Id].put(fields = ("foo", 1)) def traceValueLong() = Trace.Implicits.noop[Id].put(fields = ("foo", 1L)) + def traceValueFloat() = Trace.Implicits.noop[Id].put(fields = ("foo", 1.0f)) + def traceValueDouble() = Trace.Implicits.noop[Id].put(fields = ("foo", 1.0d)) } From f8b4f84917472a54419d7ec7d12b9d584f727e31 Mon Sep 17 00:00:00 2001 From: Michael Pilquist Date: Sat, 1 Oct 2022 20:26:54 -0400 Subject: [PATCH 171/178] Fix typo --- modules/core/shared/src/main/scala/Span.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/shared/src/main/scala/Span.scala b/modules/core/shared/src/main/scala/Span.scala index d213b002..b485bf72 100644 --- a/modules/core/shared/src/main/scala/Span.scala +++ b/modules/core/shared/src/main/scala/Span.scala @@ -57,7 +57,7 @@ object Span { })) /** - * A no-op `Span` implementation which ignors all child span creation. + * A no-op `Span` implementation which ignores all child span creation. */ def noop[F[_]: Applicative]: Span[F] = new NoopSpan From 30dfeded8876eeec619533571f16852123290dc0 Mon Sep 17 00:00:00 2001 From: Michael Pilquist Date: Sat, 1 Oct 2022 20:47:32 -0400 Subject: [PATCH 172/178] Update workflow --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a3c0ddf..c00dbb78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,11 +94,11 @@ jobs: - name: Make target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/0.1') - run: mkdir -p modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/noop/native/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/mtl/jvm/target modules/lightstep/target project/target + run: mkdir -p modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/noop/native/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/log-odin/target modules/mtl/jvm/target modules/lightstep/target project/target - name: Compress target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/0.1') - run: tar cf targets.tar modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/noop/native/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/mtl/jvm/target modules/lightstep/target project/target + run: tar cf targets.tar modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/noop/native/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/log-odin/target modules/mtl/jvm/target modules/lightstep/target project/target - name: Upload target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/0.1') From 2bee7083a4881d166ae03baec0142da694a56be8 Mon Sep 17 00:00:00 2001 From: Michael Pilquist Date: Sat, 1 Oct 2022 20:51:52 -0400 Subject: [PATCH 173/178] Update build.sbt Co-authored-by: Arman Bilge --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index 3e929ef2..0ebef7b3 100644 --- a/build.sbt +++ b/build.sbt @@ -324,6 +324,7 @@ lazy val logOdin = project .settings( name := "natchez-log-odin", description := "Logging bindings for Natchez, using Odin.", + tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.1.7").toMap, libraryDependencies ++= Seq( "io.circe" %% "circe-core" % "0.14.1", "com.github.valskalla" %% "odin-core" % "0.13.0", From 34b6b0ed21c76cc123690777b1c1d3f460a9d563 Mon Sep 17 00:00:00 2001 From: Michael Pilquist Date: Sat, 1 Oct 2022 20:52:22 -0400 Subject: [PATCH 174/178] Fix headers in odin module --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index 3e929ef2..25a130a5 100644 --- a/build.sbt +++ b/build.sbt @@ -321,6 +321,7 @@ lazy val logOdin = project .in(file("modules/log-odin")) .dependsOn(core.jvm) .enablePlugins(AutomateHeaderPlugin) + .settings(commonSettings) .settings( name := "natchez-log-odin", description := "Logging bindings for Natchez, using Odin.", From 51104be3c4fc0a78b531b3988d120c93cc27d9a5 Mon Sep 17 00:00:00 2001 From: Michael Pilquist Date: Sun, 2 Oct 2022 08:55:27 -0400 Subject: [PATCH 175/178] Fix doc typo --- modules/opencensus/README.md | 4 ++-- modules/opentelemetry/README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/opencensus/README.md b/modules/opencensus/README.md index ccf9a099..259c1542 100644 --- a/modules/opencensus/README.md +++ b/modules/opencensus/README.md @@ -1,7 +1,7 @@ # OpenCensus OpenCensus is capable of exporting to different collector types. - Exporters are added registered globally against a singleton registry. + Exporters are registered globally against a singleton registry. There is nothing stopping someone registering a new exporter outside of a side effect, so it is up to the user whether to do so inside the effects system or not. @@ -24,4 +24,4 @@ The recommended approach for registering exporters is to use a resource. OcAgentTraceExporter.unregister() )) .flatMap(_ => Resource.liftF(entryPoint[F])) -``` \ No newline at end of file +``` diff --git a/modules/opentelemetry/README.md b/modules/opentelemetry/README.md index 3ee922cb..6b88687e 100644 --- a/modules/opentelemetry/README.md +++ b/modules/opentelemetry/README.md @@ -1,6 +1,6 @@ # OpenTelemetry -OpenTelemetry is capable of exporting to different collector types. Exporters are added registered globally against a +OpenTelemetry is capable of exporting to different collector types. Exporters are registered globally against a singleton registry. There is nothing stopping someone registering a new exporter outside of a side effect, so it is up to the user whether to do so inside the effects system or not. @@ -62,4 +62,4 @@ def entrypoint[F[_] : Sync](projectId: String)(configure: TraceConfiguration.Bui ) .flatMap(sdk => Resource.eval(OpenTelemetry.entryPointForSdk[F](sdk))) -``` \ No newline at end of file +``` From f48ebda3e1c54a9852e0c3e9a21af5a96e0a5d54 Mon Sep 17 00:00:00 2001 From: Michael Pilquist Date: Sun, 2 Oct 2022 08:57:27 -0400 Subject: [PATCH 176/178] Update workflow --- .github/workflows/ci.yml | 4 ++-- build.sbt | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c00dbb78..62434c6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,11 +94,11 @@ jobs: - name: Make target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/0.1') - run: mkdir -p modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/noop/native/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/log-odin/target modules/mtl/jvm/target modules/lightstep/target project/target + run: mkdir -p modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/noop/native/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/log-odin/target modules/mtl/jvm/target modules/opentelemetry/target modules/lightstep/target project/target - name: Compress target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/0.1') - run: tar cf targets.tar modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/noop/native/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/log-odin/target modules/mtl/jvm/target modules/lightstep/target project/target + run: tar cf targets.tar modules/mtl/native/target modules/lightstep-grpc/target modules/log/jvm/target modules/noop/jvm/target modules/mock/target modules/examples/target target modules/log/native/target .js/target modules/core/native/target modules/docs/target modules/lightstep-http/target modules/datadog/target modules/xray/jvm/target modules/opentracing/target modules/noop/native/target modules/xray/js/target modules/core/js/target modules/noop/js/target modules/core/jvm/target .jvm/target modules/jaeger/target .native/target modules/opencensus/target modules/honeycomb/target modules/log/js/target modules/mtl/js/target modules/newrelic/target modules/log-odin/target modules/mtl/jvm/target modules/opentelemetry/target modules/lightstep/target project/target - name: Upload target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/series/0.1') diff --git a/build.sbt b/build.sbt index a5762682..81cae424 100644 --- a/build.sbt +++ b/build.sbt @@ -65,6 +65,7 @@ lazy val root = tlCrossRootProject.aggregate( jaeger, honeycomb, opencensus, + opentelemetry, lightstep, lightstepGrpc, lightstepHttp, opentracing, datadog, @@ -194,7 +195,7 @@ lazy val opentracing = project lazy val opentelemetry = project .in(file("modules/opentelemetry")) - .dependsOn(coreJVM) + .dependsOn(core.jvm) .enablePlugins(AutomateHeaderPlugin) .settings(commonSettings) .settings( From 3e3e327d0d53f128f1c9e5080f9c929ad0d7bf95 Mon Sep 17 00:00:00 2001 From: Michael Pilquist Date: Sun, 2 Oct 2022 09:02:48 -0400 Subject: [PATCH 177/178] Mima --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index 81cae424..9b1e1590 100644 --- a/build.sbt +++ b/build.sbt @@ -201,6 +201,7 @@ lazy val opentelemetry = project .settings( name := "natchez-opentelemetry", description := "Base OpenTelemetry Utilities for Natchez", + tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.1.7").toMap, libraryDependencies ++= Seq( "org.scala-lang.modules" %% "scala-collection-compat" % collectionCompatVersion, "io.opentelemetry" % "opentelemetry-sdk" % "1.12.0" From 1aab064d83581d599bc157c45fc4a64a4f39bdf0 Mon Sep 17 00:00:00 2001 From: mpilquist Date: Tue, 15 Nov 2022 20:16:24 -0500 Subject: [PATCH 178/178] Update otel doc page --- .../docs/src/main/paradox/backends/opentelemetry.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/docs/src/main/paradox/backends/opentelemetry.md b/modules/docs/src/main/paradox/backends/opentelemetry.md index b56aaf6d..95850ce7 100644 --- a/modules/docs/src/main/paradox/backends/opentelemetry.md +++ b/modules/docs/src/main/paradox/backends/opentelemetry.md @@ -15,13 +15,9 @@ Then add any exporter, for example: @@dependency[sbt,Maven,Gradle] { group="io.opentelemetry" artifact="opentelemetry-exporter-otlp" -version="1.4.0-SNAPSHOT" +version="1.12.0" } -## Note on the OpenTelemetry version numbers - -Currently, this depends on `1.4.0-SNAPSHOT` because of a bug I discovered upstream while writing this, where the `shutdown()` calls could block indefinitely, this has been fixed in the snapshot build, and this note can be removed once there's a stable release with this fix. - ## Configuring an OpenTelemetry entrypoint There are two methods you'll need to construct an `OpenTelemetry` `EndPoint`. @@ -29,7 +25,8 @@ There are two methods you'll need to construct an `OpenTelemetry` `EndPoint`. `OpenTelemetry.lift` is used to turn an `F[_]` that constructs a `SpanExporter`, `SpanProcessor` or `SdkTraceProvider` into a `Resource` that will shut it down cleanly. This takes a `String` of what you've constructed, so we can give a nice error if it fails to shut down cleanly. -The `OpenTelemetry.entryPoint` method takes a boolean called `globallyRegister` which tells it whether to register this `OpenTelemetrySdk` globally, this may be helpful if you have other java dependencies that use the global tracer, it defaults to false. +The `OpenTelemetry.entryPoint` method takes a boolean called `globallyRegister` which tells it whether to register this `OpenTelemetry` globally. This may be helpful if you have other Java dependencies that use the global tracer. It defaults to false. + It also takes an `OpenTelemetrySdkBuilder => Resource[F, OpenTelemetrySdkBuilder]` so that you can configure the Sdk. Here's an example of configuring one with the `otlp` exporter with batch span processing: @@ -86,4 +83,4 @@ import io.opentelemetry.sdk.trace.`export`.BatchSpanProcessor } )} } yield ep -``` \ No newline at end of file +```